Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
statement.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file statement.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 #ifndef __ODBCXX_STATEMENT_H
23 #define __ODBCXX_STATEMENT_H
24 
25 #include <RDBC/odbc++/setup.h>
26 #include <RDBC/odbc++/types.h>
28 #include <RDBC/odbc++/connection.h>
29 
30 namespace odbc {
31 
32  class ResultSet;
33  class DriverInfo;
34 
37  friend class Connection;
38  friend class ResultSet;
39  friend class DatabaseMetaData;
40 
41  protected:
43  SQLHSTMT hstmt_;
45 
46  const DriverInfo* _getDriverInfo() const {
47  return connection_->_getDriverInfo();
48  }
49 
50  private:
52 
56 
57  //used internally
60  STATE_OPEN
61  };
62 
64 
65  std::vector<ODBCXX_STRING> batches_;
66 
67  void _registerResultSet(ResultSet* rs);
68  void _unregisterResultSet(ResultSet* rs);
69 
70  void _applyResultSetType();
71 
72  ResultSet* _getTypeInfo();
73  ResultSet* _getTables(const ODBCXX_STRING& catalog,
74  const ODBCXX_STRING& schema,
75  const ODBCXX_STRING& tableName,
76  const ODBCXX_STRING& types);
77 
78  ResultSet* _getTablePrivileges(const ODBCXX_STRING& catalog,
79  const ODBCXX_STRING& schema,
80  const ODBCXX_STRING& tableName);
81 
82  ResultSet* _getColumnPrivileges(const ODBCXX_STRING& catalog,
83  const ODBCXX_STRING& schema,
84  const ODBCXX_STRING& tableName,
85  const ODBCXX_STRING& columnName);
86 
87  ResultSet* _getPrimaryKeys(const ODBCXX_STRING& catalog,
88  const ODBCXX_STRING& schema,
89  const ODBCXX_STRING& tableName);
90 
91  ResultSet* _getColumns(const ODBCXX_STRING& catalog,
92  const ODBCXX_STRING& schema,
93  const ODBCXX_STRING& tableName,
94  const ODBCXX_STRING& columnName);
95 
96  ResultSet* _getIndexInfo(const ODBCXX_STRING& catalog,
97  const ODBCXX_STRING& schema,
98  const ODBCXX_STRING& tableName,
99  bool unique, bool approximate);
100 
101  ResultSet* _getCrossReference(const ODBCXX_STRING& pc,
102  const ODBCXX_STRING& ps,
103  const ODBCXX_STRING& pt,
104  const ODBCXX_STRING& fc,
105  const ODBCXX_STRING& fs,
106  const ODBCXX_STRING& ft);
107 
108 
109  ResultSet* _getProcedures(const ODBCXX_STRING& catalog,
110  const ODBCXX_STRING& schema,
111  const ODBCXX_STRING& procName);
112 
113  ResultSet* _getProcedureColumns(const ODBCXX_STRING& catalog,
114  const ODBCXX_STRING& schema,
115  const ODBCXX_STRING& procName,
116  const ODBCXX_STRING& colName);
117 
118  ResultSet* _getSpecialColumns(const ODBCXX_STRING& catalog,
119  const ODBCXX_STRING& schema,
120  const ODBCXX_STRING& table,
121  int what,int scope,int nullable);
122 
123  protected:
124  Statement(Connection* con, SQLHSTMT hstmt,
125  int resultSetType, int resultSetConcurrency);
126 
127  //utilities
128  SQLUINTEGER _getNumericOption(SQLINTEGER optnum);
129  ODBCXX_STRING _getStringOption(SQLINTEGER optnum);
130 
131  void _setNumericOption(SQLINTEGER optnum, SQLUINTEGER value);
132  void _setStringOption(SQLINTEGER optnum, const ODBCXX_STRING& value);
133 
134 #if ODBCVER >= 0x0300
135  SQLPOINTER _getPointerOption(SQLINTEGER optnum);
136  void _setPointerOption(SQLINTEGER optnum, SQLPOINTER value);
137 #endif
138 
139  //this returns true if we have a result set pending
140  bool _checkForResults();
141 
142  //this _always_ returns a ResultSet. If hideMe is true, this statement
143  //becomes 'owned' by the ResultSet
144  ResultSet* _getResultSet(bool hideMe =false);
145 
146  //this is called before a Statement (or any of the derived classes)
147  //is executed
148  void _beforeExecute();
149 
150  //this is called after a successeful execution
151  void _afterExecute();
152 
153 
154  public:
158  virtual ~Statement();
159 
161  Connection* getConnection();
162 
163 
165  void cancel();
166 
174  virtual bool execute(const ODBCXX_STRING& sql);
175 
180  virtual ResultSet* executeQuery(const ODBCXX_STRING& sql);
181 
185  virtual int executeUpdate(const ODBCXX_STRING& sql);
186 
192  int getUpdateCount();
193 
195  ResultSet* getResultSet();
196 
201  bool getMoreResults();
202 
204  void setCursorName(const ODBCXX_STRING& name);
205 
209  int getFetchSize() {
210  return fetchSize_;
211  }
212 
214  void setFetchSize(int size);
215 
218  return resultSetConcurrency_;
219  }
220 
223  return resultSetType_;
224  }
225 
227  int getQueryTimeout();
229  void setQueryTimeout(int seconds);
230 
232  int getMaxRows();
234  void setMaxRows(int maxRows);
235 
237  int getMaxFieldSize();
239  void setMaxFieldSize(int maxFieldSize);
240 
246  void setEscapeProcessing(bool on);
247 
252  bool getEscapeProcessing();
253  };
254 
255 
256 
257 }; // namespace odbc
258 
259 
260 #endif // __ODBCXX_STATEMENT_H