Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
8dea7e97
Commit
8dea7e97
authored
Nov 16, 2018
by
Steven Murray
Browse files
rdbms::Conn::executeNonQuery() now calls wrapper::Conn::executeNonQuery()
parent
26860fc4
Changes
7
Hide whitespace changes
Inline
Side-by-side
rdbms/Conn.cpp
View file @
8dea7e97
...
...
@@ -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"
);
}
}
...
...
rdbms/Conn.hpp
View file @
8dea7e97
...
...
@@ -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 statement
s
.
* @param autocommitMode The autocommit mode of the statement.
*/
void
executeNonQuery
(
const
std
::
string
&
sql
,
const
AutocommitMode
autocommitMode
);
...
...
rdbms/wrapper/Conn.hpp
View file @
8dea7e97
...
...
@@ -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.
*
...
...
rdbms/wrapper/OcciConn.cpp
View file @
8dea7e97
...
...
@@ -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
//------------------------------------------------------------------------------
...
...
rdbms/wrapper/OcciConn.hpp
View file @
8dea7e97
...
...
@@ -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.
*
...
...
rdbms/wrapper/SqliteConn.cpp
View file @
8dea7e97
...
...
@@ -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
//------------------------------------------------------------------------------
...
...
rdbms/wrapper/SqliteConn.hpp
View file @
8dea7e97
...
...
@@ -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.
*
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment