diff options
author | randomdan <randomdan@localhost> | 2010-04-05 17:15:14 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2010-04-05 17:15:14 +0000 |
commit | b9b2dc0575ba01dd294264f217757a88cabafc62 (patch) | |
tree | 03851b0aa39cb2e5fade42e990179b9e7e127d24 | |
parent | lots of gcc warning fixes and a few newbies (diff) | |
download | libdbpp-odbc-b9b2dc0575ba01dd294264f217757a88cabafc62.tar.bz2 libdbpp-odbc-b9b2dc0575ba01dd294264f217757a88cabafc62.tar.xz libdbpp-odbc-b9b2dc0575ba01dd294264f217757a88cabafc62.zip |
Minor fixes
-rw-r--r-- | libodbcpp/command.h | 4 | ||||
-rw-r--r-- | libodbcpp/connection.cpp | 8 | ||||
-rw-r--r-- | libodbcpp/param.cpp | 11 |
3 files changed, 15 insertions, 8 deletions
diff --git a/libodbcpp/command.h b/libodbcpp/command.h index 9da291c..8ef7249 100644 --- a/libodbcpp/command.h +++ b/libodbcpp/command.h @@ -25,9 +25,9 @@ namespace ODBC { void bindParamS(unsigned int i, const unsigned char *, size_t); void bindParamS(unsigned int i, std::string); void bindParamS(unsigned int i, String); - void bindParamT(unsigned int i, struct tm *); + void bindParamT(unsigned int i, const struct tm *); void bindParamT(unsigned int i, time_t); - void bindParamT(unsigned int i, const TimeTypePair & p) { bindParamT(i, p.c()); } + void bindParamT(unsigned int i, const TimeTypePair & p); const String sql; protected: diff --git a/libodbcpp/connection.cpp b/libodbcpp/connection.cpp index d1c447d..e3e92c7 100644 --- a/libodbcpp/connection.cpp +++ b/libodbcpp/connection.cpp @@ -97,9 +97,11 @@ ODBC::Connection::~Connection() int ODBC::Connection::beginTx() const { - SQLRETURN dberr = SQLSetConnectOption(conn, SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF); - if ((dberr != SQL_SUCCESS)) { - throw Error(dberr, SQL_HANDLE_DBC, conn, "Set default auto commit"); + if (txDepth == 0) { + SQLRETURN dberr = SQLSetConnectOption(conn, SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF); + if ((dberr != SQL_SUCCESS)) { + throw Error(dberr, SQL_HANDLE_DBC, conn, "Set default auto commit"); + } } txDepth += 1; return txDepth; diff --git a/libodbcpp/param.cpp b/libodbcpp/param.cpp index 7bfa415..53b55b5 100644 --- a/libodbcpp/param.cpp +++ b/libodbcpp/param.cpp @@ -125,11 +125,11 @@ ODBC::Command::bindParamS(unsigned int i, const unsigned char * val, size_t leng throw Error("%s: Bind out of bounds", __FUNCTION__); } void -ODBC::Command::bindParamT(unsigned int i, struct tm * val) +ODBC::Command::bindParamT(unsigned int i, const TimeTypePair & val) { if (i < params.size()) { _Param<TimeTypePair>* p = Param::makeParam<TimeTypePair>(params[i]); - p->value.set(*val); + p->value = val; if (!p->bound) { p->bind(this->hStmt, i + 1, SQL_C_TYPE_TIMESTAMP, SQL_TYPE_TIMESTAMP, sizeof(SQL_TIMESTAMP_STRUCT), 0, &p->value.sql(), sizeof(SQL_TIMESTAMP_STRUCT)); @@ -163,7 +163,7 @@ ODBC::Command::bindParamS(unsigned int i, const unsigned char * val) { const unsigned char * x = val; while (*val++) ; - bindParamS(i, val, val - x); + bindParamS(i, x, val - x); } void ODBC::Command::bindParamS(unsigned int i, const char * val) @@ -187,4 +187,9 @@ ODBC::Command::bindParamT(unsigned int i, time_t val) gmtime_r(&val, &t); bindParamT(i, &t); } +void +ODBC::Command::bindParamT(unsigned int i, const struct tm * val) +{ + bindParamT(i, TimeTypePair(*val)); +} |