00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __ODBCXX_PREPAREDSTATEMENT_H
00024 #define __ODBCXX_PREPAREDSTATEMENT_H
00025
00026 #include <odbc++/setup.h>
00027 #include <odbc++/types.h>
00028 #include <odbc++/statement.h>
00029
00030 #if defined(ODBCXX_HAVE_ISO_CXXLIB)
00031 # include <iosfwd>
00032 #else
00033 # include <iostream>
00034 #endif
00035
00036 namespace odbc {
00037
00038 class Rowset;
00039
00062 class ODBCXX_EXPORT PreparedStatement : public Statement {
00063 friend class Connection;
00064
00065 private:
00066 void _prepare();
00067 void _setupParams();
00068
00069 protected:
00070 ODBCXX_STRING sql_;
00071
00072 Rowset* rowset_;
00073 size_t numParams_;
00074 std::vector<int> directions_;
00075 int defaultDirection_;
00076 bool paramsBound_;
00077
00078 PreparedStatement(Connection* con,
00079 SQLHSTMT hstmt,
00080 const ODBCXX_STRING& sql,
00081 int resultSetType,
00082 int resultSetConcurrency,
00083 int defaultDirection =SQL_PARAM_INPUT);
00084
00085 void _bindParams();
00086 void _unbindParams();
00087
00088 void _checkParam(int idx,
00089 int* allowed, int numAllowed,
00090 int defPrec, int defScale);
00091
00092 public:
00094 virtual ~PreparedStatement();
00095
00102 void clearParameters();
00103
00108 bool execute();
00109
00117 ResultSet* executeQuery();
00118
00120 int executeUpdate();
00121
00126 void setDouble(int idx, double val);
00127
00132 void setBoolean(int idx, bool val);
00133
00138 void setByte(int idx, signed char val);
00139
00140
00145 void setBytes(int idx, const ODBCXX_BYTES& val);
00146
00151 void setDate(int idx, const Date& val);
00152
00157 void setFloat(int idx, float val);
00158
00159
00164 void setInt(int idx, int val);
00165
00170 void setLong(int idx, Long val);
00171
00176 void setShort(int idx, short val);
00177
00182 void setString(int idx, const ODBCXX_STRING& val);
00183
00188 void setTime(int idx, const Time& val);
00189
00194 void setTimestamp(int idx, const Timestamp& val);
00195
00201 void setAsciiStream(int idx, ODBCXX_STREAM* s, int len);
00202
00208 void setBinaryStream(int idx, ODBCXX_STREAM* s, int len);
00209
00210
00216 void setNull(int idx, int sqlType);
00217 };
00218
00219
00220 }
00221
00222 #endif // __ODBCXX_PREPAREDSTATEMENT_H