30#include <sptk5/db/PoolDatabaseConnection.h>
34#include "DatabaseField.h"
35#include <sptk5/db/OracleEnvironment.h>
36#include <sptk5/db/OracleStatement.h>
37#include <src/drivers/Oracle/OracleBulkInsertQuery.h>
48class OracleBulkInsertQuery;
55class SP_EXPORT OracleConnection
56 :
public PoolDatabaseConnection
60 friend class OracleStatement;
63 using Environment = oracle::occi::Environment;
64 using Connection = oracle::occi::Connection;
65 using Statement = oracle::occi::Statement;
66 using Type = oracle::occi::Type;
71 Connection* connection()
const
73 return m_connection.get();
79 Environment* environment()
const
81 return m_environment.handle();
84 Statement* createStatement(
const std::string& sql)
86 return m_connection->createStatement(sql);
93 void _openDatabase(
const String& connectionString)
override;
105 void _bulkInsert(
const String& fullTableName,
const Strings& columnNames,
106 const std::vector<VariantVector>& data)
override;
116 void _executeBatchSQL(
const Strings& batchSQL, Strings* errors)
override;
122 explicit OracleConnection(
const String& connectionString =
"", std::chrono::seconds connectTimeout = std::chrono::seconds(60));
127 ~OracleConnection()
override;
132 void closeDatabase()
override;
137 bool active()
const override;
142 DBHandle handle()
const override;
147 String nativeConnectionString()
const override;
152 String driverDescription()
const override;
164 static std::map<OracleConnection*, std::shared_ptr<OracleConnection>> s_oracleConnections;
170 void driverBeginTransaction()
override;
176 void driverEndTransaction(
bool commit)
override;
182 String queryError(
const Query* query)
const override;
187 void queryAllocStmt(Query* query)
override;
192 void queryFreeStmt(Query* query)
override;
197 void queryCloseStmt(Query* query)
override;
202 void queryPrepare(Query* query)
override;
207 void queryExecute(Query* query)
override;
212 int queryColCount(Query* query)
override;
217 void queryBindParameters(Query* query)
override;
222 void queryOpen(Query* query)
override;
224 void queryColAttributes(Query* query, int16_t column, int16_t descType, int32_t& value)
override;
225 void queryColAttributes(Query* query, int16_t column, int16_t descType,
char* buff,
int len)
override;
230 void queryFetch(Query* query)
override;
238 String paramMark(
unsigned paramIndex)
override;
241 using SConnection = std::shared_ptr<Connection>;
243 mutable std::mutex m_mutex;
244 OracleEnvironment m_environment;
245 SConnection m_connection;
246 std::string m_lastError;
248 void executeMultipleStatements(
const Strings& statements, Strings* errors);
250 static void setMaxParamSizes(
const CParamVector& enumeratedParams, Statement* stmt,
253 static void createQueryFieldsFromMetadata(Query* query, oracle::occi::ResultSet* resultSet);
256 sptk::OracleBulkInsertQuery& insertQuery,
const VariantVector& row);
264VariantDataType OracleTypeToVariantType(OracleConnection::Type oracleType,
int scale);
271OracleConnection::Type VariantTypeToOracleType(
VariantDataType dataType);
273#define throwOracleException(description) \
275 m_lastError = description; \
276 throwDatabaseException(m_lastError); \
287[[maybe_unused]] SP_DRIVER_EXPORT
void* oracle_create_connection(
const char* connectionString,
size_t connectionTimeoutSeconds);
288[[maybe_unused]] SP_DRIVER_EXPORT
void oracle_destroy_connection(
void* connection);
DatabaseObjectType
Definition: PoolDatabaseConnection.h:70
std::map< std::string, QueryColumnTypeSize, std::less<> > QueryColumnTypeSizeMap
Definition: PoolDatabaseConnection.h:95
std::vector< SQueryParameter > CParamVector
Definition: QueryParameterList.h:47
std::vector< QueryColumnTypeSize > QueryColumnTypeSizeVector
Definition: PoolDatabaseConnection.h:90
VariantDataType
Definition: VariantData.h:44
std::vector< Variant > VariantVector
Definition: Variant.h:567