libodbc++  0.2.5
preparedstatement.h
1 /*
2  This file is part of libodbc++.
3 
4  Copyright (C) 1999-2000 Manush Dodunekov <manush@stendahls.net>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING. If not, write to
18  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  Boston, MA 02111-1307, USA.
20 */
21 
22 
23 #ifndef __ODBCXX_PREPAREDSTATEMENT_H
24 #define __ODBCXX_PREPAREDSTATEMENT_H
25 
26 #include <odbc++/setup.h>
27 #include <odbc++/types.h>
28 #include <odbc++/statement.h>
29 
30 #if defined(ODBCXX_HAVE_ISO_CXXLIB)
31 # include <iosfwd>
32 #else
33 # include <iostream>
34 #endif
35 
36 #include <set>
37 
38 namespace odbc {
39 
40  class Rowset;
41 
63  class ODBCXX_EXPORT PreparedStatement : public Statement {
64  friend class Connection;
65 
66  private:
67  void _prepare();
68  void _setupParams();
69 
70  protected:
71  ODBCXX_STRING sql_;
72  //here we store the parameters
73  Rowset* rowset_;
74  size_t numParams_;
75  std::vector<int> directions_;
76  std::set<SQLUINTEGER> columnIndicies_;
77  int defaultDirection_;
78  bool paramsBound_;
79 
81  SQLHSTMT hstmt,
82  const ODBCXX_STRING& sql,
83  int resultSetType,
84  int resultSetConcurrency,
85  int defaultDirection =SQL_PARAM_INPUT);
86 
87  void _bindParams();
88  void _unbindParams();
89 
90  void _checkParam(int idx,
91  int* allowed, int numAllowed,
92  int defPrec, int defScale);
93 
94  public:
96  virtual ~PreparedStatement();
97 
104  void clearParameters();
105 
110  bool execute();
111 
118  ResultSet* executeQuery();
119 
121  int executeUpdate();
122 
127  void setDouble(int idx, double val);
128 
133  void setBoolean(int idx, bool val);
134 
139  void setByte(int idx, signed char val);
140 
145  void setBytes(int idx, const ODBCXX_BYTES& val);
146 
151  void setDate(int idx, const Date& val);
152 
157  void setFloat(int idx, float val);
158 
159 #ifdef ODBCXX_HAVE_STRUCT_GUID
160 
164  void setGuid(int idx, Guid val);
165 #endif
166 
171  void setInt(int idx, int val);
172 
177  void setLong(int idx, Long val);
178 
183  void setShort(int idx, short val);
184 
189  void setString(int idx, const ODBCXX_STRING& val);
190 
195  void setTime(int idx, const Time& val);
196 
201  void setTimestamp(int idx, const Timestamp& val);
202 
208  void setAsciiStream(int idx, ODBCXX_STREAM* s, int len);
209 
215  void setBinaryStream(int idx, ODBCXX_STREAM* s, int len);
216 
217 
223  void setNull(int idx, int sqlType);
224  };
225 
226 
227 } // namespace odbc
228 
229 #endif // __ODBCXX_PREPAREDSTATEMENT_H
The namespace where all libodbc++ classes reside.
Definition: callablestatement.h:29
An SQL DATE.
Definition: types.h:457
An SQL TIME.
Definition: types.h:575
A prepared statement.
Definition: preparedstatement.h:63
An SQL TIMESTAMP.
Definition: types.h:696
A simple non-prepared statement.
Definition: statement.h:36
A database connection.
Definition: connection.h:38
A result set.
Definition: resultset.h:38

Go back to the libodbc++ homepage