Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

odbc++/preparedstatement.h

00001 /* 
00002    This file is part of libodbc++.
00003    
00004    Copyright (C) 1999-2000 Manush Dodunekov <manush@stendahls.net>
00005    
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010    
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015    
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.  If not, write to
00018    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019    Boston, MA 02111-1307, USA.
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 
00061   class ODBCXX_EXPORT PreparedStatement : public Statement {
00062     friend class Connection;
00063 
00064   private:
00065     void _prepare();
00066     void _setupParams();
00067 
00068   protected:
00069     ODBCXX_STRING sql_;
00070     //here we store the parameters
00071     Rowset* rowset_;
00072     size_t numParams_;
00073     std::vector<int> directions_;
00074     int defaultDirection_;
00075     bool paramsBound_;
00076     
00077     PreparedStatement(Connection* con,
00078                       SQLHSTMT hstmt,
00079                       const ODBCXX_STRING& sql,
00080                       int resultSetType,
00081                       int resultSetConcurrency,
00082                       int defaultDirection =SQL_PARAM_INPUT);
00083 
00084     void _bindParams();
00085     void _unbindParams();
00086 
00087     void _checkParam(int idx,
00088                      int* allowed, int numAllowed,
00089                      int defPrec, int defScale);
00090 
00091   public:
00093     virtual ~PreparedStatement();
00094     
00101     void clearParameters();
00102     
00107     bool execute();
00108 
00111     ResultSet* executeQuery();
00112 
00114     int executeUpdate();
00115     
00120     void setDouble(int idx, double val);
00121 
00126     void setBoolean(int idx, bool val);
00127 
00132     void setByte(int idx, signed char val);
00133 
00134 
00139     void setBytes(int idx, const ODBCXX_BYTES& val);
00140 
00145     void setDate(int idx, const Date& val);
00146 
00151     void setFloat(int idx, float val);
00152 
00153 
00158     void setInt(int idx, int val);
00159 
00164     void setLong(int idx, Long val);
00165 
00170     void setShort(int idx, short val);
00171 
00176     void setString(int idx, const ODBCXX_STRING& val);
00177 
00182     void setTime(int idx, const Time& val);
00183 
00188     void setTimestamp(int idx, const Timestamp& val);
00189 
00195     void setAsciiStream(int idx, ODBCXX_STREAM* s, int len);
00196 
00202     void setBinaryStream(int idx, ODBCXX_STREAM* s, int len);
00203 
00204     
00210     void setNull(int idx, int sqlType);
00211   };
00212 
00213 
00214 }; // namespace odbc
00215 
00216 #endif // __ODBCXX_PREPAREDSTATEMENT_H

Go back to the freeodbc++ homepage