diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-12-24 04:08:56 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-12-24 04:08:56 +0000 |
commit | 63d9cbb434ec4f6e828083b99d638127cfce7a95 (patch) | |
tree | 2dfcf95372467a9119147265fccfba058c617b8a /libodbcpp/odbc-modifycommand.cpp | |
parent | Use parent glibmm (diff) | |
download | libdbpp-odbc-63d9cbb434ec4f6e828083b99d638127cfce7a95.tar.bz2 libdbpp-odbc-63d9cbb434ec4f6e828083b99d638127cfce7a95.tar.xz libdbpp-odbc-63d9cbb434ec4f6e828083b99d638127cfce7a95.zip |
ODBC files prefixed with odbc-
Diffstat (limited to 'libodbcpp/odbc-modifycommand.cpp')
-rw-r--r-- | libodbcpp/odbc-modifycommand.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/libodbcpp/odbc-modifycommand.cpp b/libodbcpp/odbc-modifycommand.cpp new file mode 100644 index 0000000..5d483c5 --- /dev/null +++ b/libodbcpp/odbc-modifycommand.cpp @@ -0,0 +1,40 @@ +#include "odbc-modifycommand.h" +#include "odbc-error.h" + +ODBC::ModifyCommand::ModifyCommand(const ODBC::Connection & c, const std::string & sql) : + DB::Command(sql), + ODBC::Command(c, sql), + DB::ModifyCommand(sql) +{ +} + +ODBC::ModifyCommand::~ModifyCommand() +{ +} + +unsigned int +ODBC::ModifyCommand::execute(bool anc) +{ + if (connection.txIsAborted()) { + throw Error("Transaction has been aborted, not issuing any more commands"); + } + RETCODE rc = SQLExecute(hStmt); + if (!SQL_SUCCEEDED(rc)) { + if (rc != SQL_NO_DATA || !anc) { + connection.abortTx(); + throw Error(rc, SQL_HANDLE_STMT, hStmt, "ODBC::ModifyCommand::execute SQLExecute"); + } + } + SQLLEN rows; + rc = SQLRowCount(hStmt, &rows); + if (!SQL_SUCCEEDED(rc)) { + connection.abortTx(); + throw Error(rc, SQL_HANDLE_STMT, hStmt, "ODBC::ModifyCommand::execute SQLRowCount"); + } + if (rows > 0 || anc) { + return rows; + } + connection.abortTx(); + throw Error("No rows affected"); +} + |