+ SQLRETURN sr = SQLPrepare(stmt, (SQLCHAR*)q.c_str(), SQL_NTS);
+ if (!SQL_SUCCEEDED(sr)) {
+ m_log.error("SQLPrepare failed (t=%s, c=%s, k=%s)", table, context, key);
+ log_error(stmt, SQL_HANDLE_STMT);
+ throw IOException("ODBC StorageService failed to insert record.");
+ }
+ m_log.debug("SQLPrepare() succeded. SQL: %s", q.c_str());
+
+ SQLINTEGER b_ind = SQL_NTS;
+ sr = SQLBindParam(stmt, 1, SQL_C_CHAR, SQL_VARCHAR, 0, 0, const_cast<char*>(context), &b_ind);
+ if (!SQL_SUCCEEDED(sr)) {
+ m_log.error("SQLBindParam failed (context = %s)", context);
+ log_error(stmt, SQL_HANDLE_STMT);
+ throw IOException("ODBC StorageService failed to insert record.");
+ }
+ m_log.debug("SQLBindParam succeded (context = %s)", context);
+
+ sr = SQLBindParam(stmt, 2, SQL_C_CHAR, SQL_VARCHAR, 0, 0, const_cast<char*>(key), &b_ind);
+ if (!SQL_SUCCEEDED(sr)) {
+ m_log.error("SQLBindParam failed (key = %s)", key);
+ log_error(stmt, SQL_HANDLE_STMT);
+ throw IOException("ODBC StorageService failed to insert record.");
+ }
+ m_log.debug("SQLBindParam succeded (key = %s)", key);
+
+ sr = SQLBindParam(stmt, 3, SQL_C_CHAR, (strcmp(table, TEXT_TABLE)==0 ? SQL_LONGVARCHAR : SQL_VARCHAR), 0, 0, const_cast<char*>(value), &b_ind);
+ if (!SQL_SUCCEEDED(sr)) {
+ m_log.error("SQLBindParam failed (value = %s)", value);
+ log_error(stmt, SQL_HANDLE_STMT);
+ throw IOException("ODBC StorageService failed to insert record.");
+ }
+ m_log.debug("SQLBindParam succeded (value = %s)", value);
+
+ //freeSafeSQL(scontext, context);
+ //freeSafeSQL(skey, key);
+ //freeSafeSQL(svalue, value);
+ //m_log.debug("SQL: %s", q.c_str());
+
+ sr=SQLExecute(stmt);