sptk2 logo
SPTK Home Page
OracleStatement.h
1/*
2╔══════════════════════════════════════════════════════════════════════════════╗
3║ SIMPLY POWERFUL TOOLKIT (SPTK) ║
4╟──────────────────────────────────────────────────────────────────────────────╢
5║ copyright © 1999-2022 Alexey Parshin. All rights reserved. ║
6║ email alexeyp@gmail.com ║
7╚══════════════════════════════════════════════════════════════════════════════╝
8┌──────────────────────────────────────────────────────────────────────────────┐
9│ This library is free software; you can redistribute it and/or modify it │
10│ under the terms of the GNU Library General Public License as published by │
11│ the Free Software Foundation; either version 2 of the License, or (at your │
12│ option) any later version. │
13│ │
14│ This library is distributed in the hope that it will be useful, but │
15│ WITHOUT ANY WARRANTY; without even the implied warranty of │
16│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library │
17│ General Public License for more details. │
18│ │
19│ You should have received a copy of the GNU Library General Public License │
20│ along with this library; if not, write to the Free Software Foundation, │
21│ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. │
22│ │
23│ Please report all bugs and problems to alexeyp@gmail.com. │
24└──────────────────────────────────────────────────────────────────────────────┘
25*/
26
27#pragma once
28
29#include <occi.h>
30
31#include <cstdio>
32#include <list>
33#include <string>
34
35#include "DatabaseField.h"
36#include <sptk5/FieldList.h>
37#include <sptk5/db/DatabaseStatement.h>
38
39namespace sptk {
40
41class OracleConnection;
42
47 : public DatabaseStatement<OracleConnection, oracle::occi::Statement>
48{
49public:
50 using Connection = oracle::occi::Connection;
51 using Statement = oracle::occi::Statement;
52 using ResultSet = oracle::occi::ResultSet;
53 using MetaData = oracle::occi::MetaData;
54
60 OracleStatement(OracleConnection* connection, const std::string& sql);
61
66
71
75 ~OracleStatement() override;
76
81
86
90 void setParameterValues() override;
91
96 void execute(bool inTransaction) override;
97
103 void execBulk(bool inTransaction, bool lastIteration);
104
108 void close() override;
109
113 void fetch() override
114 {
115 if (m_resultSet)
116 {
117 state().eof = (m_resultSet->next() == ResultSet::END_OF_FETCH);
118 }
119 }
120
125 {
126 return m_resultSet;
127 }
128
129 void getOutputParameters(FieldList& fields);
130
131private:
132 Statement* m_createClobStatement {nullptr};
133 Statement* m_createBlobStatement {nullptr};
134 ResultSet* m_resultSet {nullptr};
135
136 /*
137 * Index of output parameters
138 */
139 std::vector<unsigned> m_outputParamIndex;
140
147 void setClobParameter(uint32_t parameterIndex, unsigned char* data, uint32_t dataSize);
148
155 void setBlobParameter(uint32_t parameterIndex, unsigned char* data, uint32_t dataSize);
156
162 void getBLOBOutputParameter(unsigned int index, const SDatabaseField& field) const;
163
169 void getCLOBOutputParameter(unsigned int index, const SDatabaseField& field) const;
170
176 void setCLOBParameterValue(unsigned int parameterIndex, QueryParameter& parameter);
177
183 void setBLOBParameterValue(unsigned int parameterIndex, QueryParameter& parameter);
184
190 void setDateParameterValue(unsigned int parameterIndex, const QueryParameter& parameter);
191
197 void setDateTimeParameterValue(unsigned int parameterIndex, const QueryParameter& parameter);
198
204 void setInt64ParamValue(unsigned int parameterIndex, const QueryParameter& parameter);
205
211 void setBooleanParamValue(unsigned int parameterIndex, const QueryParameter& parameter);
212
218 void setStringParamValue(unsigned int parameterIndex, const QueryParameter& parameter);
219
225 void setFloatParamValue(unsigned int parameterIndex, const QueryParameter& parameter);
226
232 void setIntParamValue(unsigned int parameterIndex, const QueryParameter& parameter);
233
234 void getDateOutputParameter(unsigned int index, const SDatabaseField& field) const;
235
236 void getDateTimeOutputParameter(unsigned int index, const SDatabaseField& field) const;
237};
238
239} // namespace sptk
Definition: DatabaseStatement.h:38
Definition: FieldList.h:50
Definition: OracleStatement.h:48
OracleStatement & operator=(const OracleStatement &)=delete
oracle::occi::MetaData MetaData
Oracle result set metdata type.
Definition: OracleStatement.h:53
OracleStatement & operator=(OracleStatement &&)=default
void execBulk(bool inTransaction, bool lastIteration)
~OracleStatement() override
oracle::occi::Connection Connection
Oracle connection type.
Definition: OracleStatement.h:50
void fetch() override
Definition: OracleStatement.h:113
oracle::occi::Statement Statement
Oracle statement type.
Definition: OracleStatement.h:51
void setParameterValues() override
OracleStatement(OracleStatement &&)=default
OracleStatement(const OracleStatement &)=delete
oracle::occi::ResultSet ResultSet
Oracle result set type.
Definition: OracleStatement.h:52
void close() override
ResultSet * resultSet()
Definition: OracleStatement.h:124
OracleStatement(OracleConnection *connection, const std::string &sql)
void execute(bool inTransaction) override

Fri Oct 14 2022 09:58:31: SPTK 5.4.1