Commit 8dea7e97 authored by Steven Murray's avatar Steven Murray
Browse files

rdbms::Conn::executeNonQuery() now calls wrapper::Conn::executeNonQuery()

parent 26860fc4
......@@ -113,11 +113,10 @@ void Conn::executeNonQueries(const std::string &sqlStmts, const AutocommitMode a
// executeNonQuery
//------------------------------------------------------------------------------
void Conn::executeNonQuery(const std::string &sql, const AutocommitMode autocommitMode) {
try {
auto stmt = createStmt(sql);
stmt.executeNonQuery(autocommitMode);
} catch(exception::Exception &ex) {
throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.what());
if(nullptr != m_connAndStmts && nullptr != m_connAndStmts->conn) {
m_connAndStmts->conn->executeNonQuery(sql,autocommitMode);
} else {
throw exception::Exception(std::string(__FUNCTION__) + " failed: Conn does not contain a connection");
}
}
......
......@@ -91,8 +91,7 @@ public:
* statements and calls executeNonQuery() for each individual statement found.
*
* Please note that each statement should be a non-query terminated by a
* semicolon and that each individual statement will be executed with
* autocommit ON.
* semicolon.
*
* @param sqlStmts The SQL statements to be executed.
* @param autocommitMode The autocommit mode of the statements.
......@@ -100,11 +99,10 @@ public:
void executeNonQueries(const std::string &sqlStmts, const AutocommitMode autocommitMode);
/**
* Convenience method that wraps Conn::createStmt() followed by
* Stmt::executeNonQuery().
* Executes the statement.
*
* @param sql The SQL statement.
* @param autocommitMode The autocommit mode of the statements.
* @param autocommitMode The autocommit mode of the statement.
*/
void executeNonQuery(const std::string &sql, const AutocommitMode autocommitMode);
......
......@@ -45,6 +45,14 @@ public:
*/
virtual void close() = 0;
/**
* Executes the statement.
*
* @param sql The SQL statement.
* @param autocommitMode The autocommit mode of the statement.
*/
virtual void executeNonQuery(const std::string &sql, const AutocommitMode autocommitMode) = 0;
/**
* Creates a prepared statement.
*
......
......@@ -17,6 +17,7 @@
*/
#include "common/exception/Exception.hpp"
#include "common/exception/LostDatabaseConnection.hpp"
#include "common/make_unique.hpp"
#include "common/threading/MutexLocker.hpp"
#include "rdbms/wrapper/OcciConn.hpp"
......@@ -65,6 +66,18 @@ void OcciConn::close() {
}
}
//------------------------------------------------------------------------------
// executeNonQuery
//------------------------------------------------------------------------------
void OcciConn::executeNonQuery(const std::string &sql, const AutocommitMode autocommitMode) {
try {
auto stmt = createStmt(sql);
stmt->executeNonQuery(AutocommitMode::AUTOCOMMIT_OFF);
} catch(exception::Exception &ex) {
throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str());
}
}
//------------------------------------------------------------------------------
// createStmt
//------------------------------------------------------------------------------
......
......@@ -60,6 +60,14 @@ public:
*/
void close() override;
/**
* Executes the statement.
*
* @param sql The SQL statement.
* @param autocommitMode The autocommit mode of the statement.
*/
void executeNonQuery(const std::string &sql, const AutocommitMode autocommitMode) override;
/**
* Creates a prepared statement.
*
......
......@@ -96,6 +96,18 @@ void SqliteConn::close() {
}
}
//------------------------------------------------------------------------------
// executeNonQuery
//------------------------------------------------------------------------------
void SqliteConn::executeNonQuery(const std::string &sql, const AutocommitMode autocommitMode) {
try {
auto stmt = createStmt(sql);
stmt->executeNonQuery(AutocommitMode::AUTOCOMMIT_ON);
} catch(exception::Exception &ex) {
throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str());
}
}
//------------------------------------------------------------------------------
// createStmt
//------------------------------------------------------------------------------
......
......@@ -62,6 +62,14 @@ public:
*/
void close() override;
/**
* Executes the statement.
*
* @param sql The SQL statement.
* @param autocommitMode The autocommit mode of the statement.
*/
void executeNonQuery(const std::string &sql, const AutocommitMode autocommitMode) override;
/**
* Creates a prepared statement.
*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment