diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-12-29 02:42:43 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-12-29 06:00:07 +0000 |
commit | be237957454cd7a4e84a5a603bdef6ab3ab8b8e1 (patch) | |
tree | bfe7f06152b2d453bcd097d9913918473d8fecd7 /libodbcpp/odbc-command.cpp | |
parent | Remove rebind (diff) | |
download | libdbpp-odbc-be237957454cd7a4e84a5a603bdef6ab3ab8b8e1.tar.bz2 libdbpp-odbc-be237957454cd7a4e84a5a603bdef6ab3ab8b8e1.tar.xz libdbpp-odbc-be237957454cd7a4e84a5a603bdef6ab3ab8b8e1.zip |
Reshuffle and add new exceptions
Diffstat (limited to 'libodbcpp/odbc-command.cpp')
-rw-r--r-- | libodbcpp/odbc-command.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/libodbcpp/odbc-command.cpp b/libodbcpp/odbc-command.cpp index d96234d..43572c8 100644 --- a/libodbcpp/odbc-command.cpp +++ b/libodbcpp/odbc-command.cpp @@ -9,23 +9,23 @@ ODBC::Command::Command(const Connection & c, const std::string & s) : { RETCODE rc = SQLAllocHandle(SQL_HANDLE_STMT, c.conn, &hStmt); if (!SQL_SUCCEEDED(rc)) { - throw Error(rc, SQL_HANDLE_STMT, hStmt, "Allocate statement handle"); + throw Error(rc, SQL_HANDLE_STMT, hStmt); } rc = SQLSetStmtAttr(hStmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER)SQL_CURSOR_DYNAMIC, 0); if (!SQL_SUCCEEDED(rc)) { - throw ConnectionError(rc, SQL_HANDLE_STMT, hStmt, "Set scrollable cursor"); + throw ConnectionError(rc, SQL_HANDLE_STMT, hStmt); + } + rc = SQLPrepare(hStmt, (SQLCHAR*)sql.c_str(), sql.length()); + if (!SQL_SUCCEEDED(rc)) { + SQLFreeHandle(SQL_HANDLE_STMT, hStmt); + throw Error(rc, SQL_HANDLE_STMT, hStmt); } - rc = SQLPrepare(hStmt, (SQLCHAR*)sql.c_str(), sql.length()); - if (!SQL_SUCCEEDED(rc)) { - SQLFreeHandle(SQL_HANDLE_STMT, hStmt); - throw Error(rc, SQL_HANDLE_STMT, hStmt, "Prepare statement"); - } SQLSMALLINT pcount; - rc = SQLNumParams(hStmt, &pcount); - if (!SQL_SUCCEEDED(rc)) { - SQLFreeHandle(SQL_HANDLE_STMT, hStmt); - throw Error(rc, SQL_HANDLE_STMT, hStmt, "Parameter count"); - } + rc = SQLNumParams(hStmt, &pcount); + if (!SQL_SUCCEEDED(rc)) { + SQLFreeHandle(SQL_HANDLE_STMT, hStmt); + throw Error(rc, SQL_HANDLE_STMT, hStmt); + } params.resize(pcount); } |