Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
preparedstatement.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file 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 <RDBC/odbc++/setup.h>
27 #include <RDBC/odbc++/types.h>
28 #include <RDBC/odbc++/statement.h>
29 
30 #if defined(ODBCXX_HAVE_ISO_CXXLIB)
31 # include <iosfwd>
32 #else
33 # include <iostream>
34 #endif
35 
36 namespace odbc {
37 
38  class Rowset;
39 
62  friend class Connection;
63 
64  private:
65  void _prepare();
66  void _setupParams();
67 
68  protected:
70  //here we store the parameters
71  Rowset* rowset_;
72  size_t numParams_;
73  std::vector<int> directions_;
76 
78  SQLHSTMT hstmt,
79  const ODBCXX_STRING& sql,
80  int resultSetType,
81  int resultSetConcurrency,
82  int defaultDirection =SQL_PARAM_INPUT);
83 
84  void _bindParams();
85  void _unbindParams();
86 
87  void _checkParam(int idx,
88  int* allowed, int numAllowed,
89  int defPrec, int defScale);
90 
91  public:
93  virtual ~PreparedStatement();
94 
101  void clearParameters();
102 
107  bool execute();
108 
111  ResultSet* executeQuery();
112 
114  int executeUpdate();
115 
120  bool execute(const ODBCXX_STRING& /* sql */)
121  { return execute(); }
122  ResultSet* executeQuery(const ODBCXX_STRING& /* sql */)
123  { return executeQuery(); }
124  int executeUpdate(const ODBCXX_STRING& /* sql */)
125  { return executeUpdate(); }
126 
131  void setDouble(int idx, double val);
132 
137  void setBoolean(int idx, bool val);
138 
143  void setByte(int idx, signed char val);
144 
145 
150  void setBytes(int idx, const ODBCXX_BYTES& val);
151 
156  void setDate(int idx, const Date& val);
157 
162  void setFloat(int idx, float val);
163 
164 
169  void setInt(int idx, int val);
170 
175  void setLong(int idx, Long val);
176 
181  void setShort(int idx, short val);
182 
187  void setString(int idx, const ODBCXX_STRING& val);
188 
193  void setTime(int idx, const Time& val);
194 
199  void setTimestamp(int idx, const Timestamp& val);
200 
206  void setAsciiStream(int idx, ODBCXX_STREAM* s, int len);
207 
213  void setBinaryStream(int idx, ODBCXX_STREAM* s, int len);
214 
215 
221  void setNull(int idx, int sqlType);
222  };
223 
224 
225 }; // namespace odbc
226 
227 #endif // __ODBCXX_PREPAREDSTATEMENT_H