if (d_release_stmt) {
if (OCIStmtPrepare2(d_svcctx, &d_stmt, d_err, (text*)query.c_str(), query.size(), NULL, 0, OCI_NTV_SYNTAX, OCI_DEFAULT) != OCI_SUCCESS) {
// failed.
- throw SSqlException("Cannot prepare statement: " + OCIErrStr());
+ throw SSqlException("Cannot prepare statement: " + d_query + string(": ") + OCIErrStr());
}
d_init = true;
} else d_init = false;
if (d_query.size()==0) return;
if (d_init == false) {
if (OCIStmtPrepare2(d_svcctx, &d_stmt, d_err, (text*)d_query.c_str(), d_query.size(), NULL, 0, OCI_NTV_SYNTAX, OCI_DEFAULT) != OCI_SUCCESS) {
- throw SSqlException("Cannot prepare statement: " + OCIErrStr());
+ throw SSqlException("Cannot prepare statement: " + d_query + string(": ") + OCIErrStr());
}
d_init = true;
} else {
if (OCIStmtPrepare2(d_svcctx, &d_stmt, d_err, (text*)d_query.c_str(), d_query.size(), d_stmt_key, d_stmt_keysize, OCI_NTV_SYNTAX, OCI_DEFAULT) != OCI_SUCCESS) {
- throw SSqlException("Cannot prepare statement: " + OCIErrStr());
+ throw SSqlException("Cannot prepare statement: " + d_query + string(": ") + OCIErrStr());
}
}
}
SSqlStatement* bind(const string& name, int value)
{
if (d_paridx >= d_parnum)
- throw SSqlException("Attempt to bind more parameters than query has");
+ throw SSqlException("Attempt to bind more parameters than query has: " + d_query);
prepareStatement();
string zName = string(":") + name;
d_bind[d_paridx].val4 = value;
SSqlStatement* bind(const string& name, uint32_t value)
{
if (d_paridx >= d_parnum)
- throw SSqlException("Attempt to bind more parameters than query has");
+ throw SSqlException("Attempt to bind more parameters than query has: " + d_query);
prepareStatement();
string zName = string(":") + name;
d_bind[d_paridx].val4 = value;
SSqlStatement* bind(const string& name, long value)
{
if (d_paridx >= d_parnum)
- throw SSqlException("Attempt to bind more parameters than query has");
+ throw SSqlException("Attempt to bind more parameters than query has: " + d_query);
prepareStatement();
string zName = string(":") + name;
d_bind[d_paridx].val4 = value;
SSqlStatement* bind(const string& name, unsigned long value)
{
if (d_paridx >= d_parnum)
- throw SSqlException("Attempt to bind more parameters than query has");
+ throw SSqlException("Attempt to bind more parameters than query has: " + d_query);
prepareStatement();
string zName = string(":") + name;
d_bind[d_paridx].val4 = value;
SSqlStatement* bind(const string& name, long long value)
{
if (d_paridx >= d_parnum)
- throw SSqlException("Attempt to bind more parameters than query has");
+ throw SSqlException("Attempt to bind more parameters than query has: " + d_query);
prepareStatement();
string zName = string(":") + name;
d_bind[d_paridx].val8 = value;
SSqlStatement* bind(const string& name, unsigned long long value)
{
if (d_paridx >= d_parnum)
- throw SSqlException("Attempt to bind more parameters than query has");
+ throw SSqlException("Attempt to bind more parameters than query has: " + d_query);
prepareStatement();
string zName = string(":") + name;
d_bind[d_paridx].val8 = value;
SSqlStatement* bind(const string& name, const std::string& value)
{
if (d_paridx >= d_parnum)
- throw SSqlException("Attempt to bind more parameters than query has");
+ throw SSqlException("Attempt to bind more parameters than query has: " + d_query);
prepareStatement();
string zName = string(":") + name;
d_bind[d_paridx].vals = new text[value.size()+1];
SSqlStatement* bindNull(const string& name)
{
if (d_paridx >= d_parnum)
- throw SSqlException("Attempt to bind more parameters than query has");
+ throw SSqlException("Attempt to bind more parameters than query has: " + d_query);
prepareStatement();
string zName = string(":") + name;
if (OCIBindByName(d_stmt, &(d_bind[d_paridx].handle), d_err, (text*)zName.c_str(), zName.size(), NULL, 0, SQLT_STR, &d_null_ind, 0, 0, 0, 0, OCI_DEFAULT) != OCI_SUCCESS) {
ub4 iters;
if (OCIAttrGet(d_stmt, OCI_HTYPE_STMT, (dvoid*)&fntype, 0, OCI_ATTR_STMT_TYPE, d_err))
- throw SSqlException("Cannot get statement type: " + OCIErrStr());
+ throw SSqlException("Cannot get statement type: " + d_query + string(": ") + OCIErrStr());
if (fntype == OCI_STMT_SELECT) iters = 0;
else iters = 1;
d_queryResult = OCIStmtExecute(d_svcctx, d_stmt, d_err, iters, 0, NULL, NULL, OCI_DEFAULT);
if (d_queryResult != OCI_NO_DATA && d_queryResult != OCI_SUCCESS && d_queryResult != OCI_SUCCESS_WITH_INFO) {
- throw SSqlException("Cannot execute statement: " + OCIErrStr());
+ throw SSqlException("Cannot execute statement: " + d_query + string(": ") + OCIErrStr());
}
d_resnum = d_residx = 0;
// figure out what the result looks like
if (OCIAttrGet(d_stmt, OCI_HTYPE_STMT, (dvoid*)&o_resnum, 0, OCI_ATTR_ROW_COUNT, d_err))
- throw SSqlException("Cannot get statement result row count: " + OCIErrStr()); // this returns 0
+ throw SSqlException("Cannot get statement result row count: " + d_query + string(": ") + OCIErrStr()); // this returns 0
if (OCIAttrGet(d_stmt, OCI_HTYPE_STMT, (dvoid*)&o_fnum, 0, OCI_ATTR_PARAM_COUNT, d_err))
- throw SSqlException("Cannot get statement result column count: " + OCIErrStr());
+ throw SSqlException("Cannot get statement result column count: " + d_query + string(": ") + OCIErrStr());
d_residx = 0;
d_resnum = o_resnum;
for(int i=0; i < d_fnum; i++) {
if (OCIParamGet(d_stmt, OCI_HTYPE_STMT, d_err, (dvoid**)&parms, (ub4)i+1) != OCI_SUCCESS) {
- throw SSqlException("Cannot get statement result column information: " + OCIErrStr());
+ throw SSqlException("Cannot get statement result column information: " + d_query + string(": ") + OCIErrStr());
}
if (OCIAttrGet(parms, OCI_DTYPE_PARAM, (dvoid*)&(d_res[i].colsize), 0, OCI_ATTR_DATA_SIZE, d_err) != OCI_SUCCESS) {
- throw SSqlException("Cannot get statement result column information: " + OCIErrStr());
+ throw SSqlException("Cannot get statement result column information: " + d_query + string(": ") + OCIErrStr());
}
if (d_res[i].colsize == 0) {
if (OCIAttrGet(parms, OCI_DTYPE_PARAM, (dvoid*)&o_attrtype, 0, OCI_ATTR_DATA_TYPE, d_err) != OCI_SUCCESS) {
- throw SSqlException("Cannot get statement result column information: " + OCIErrStr());
+ throw SSqlException("Cannot get statement result column information: " + d_query + string(": ") + OCIErrStr());
}
// oracle 11g returns 0 for integer fields - we know oracle should return 22.
if (d_fnum > 0) {
for(int i=0;i<d_fnum;i++) {
if (OCIDefineByPos(d_stmt, &(d_res[i].handle), d_err, i+1, d_res[i].content, d_res[i].colsize+1, SQLT_STR, (dvoid*)&(d_res[i].ind), NULL, NULL, OCI_DEFAULT))
- throw SSqlException("Cannot bind result column: " + OCIErrStr());
+ throw SSqlException("Cannot bind result column: " + d_query + string(": ") + OCIErrStr());
}
}
if (d_queryResult == OCI_NO_DATA) return this;
if (d_queryResult != OCI_SUCCESS && d_queryResult != OCI_SUCCESS_WITH_INFO) {
- throw SSqlException("Cannot get next row: " + OCIErrStr());
+ throw SSqlException("Cannot get next row: " + d_query + string(": ") + OCIErrStr());
}
row.reserve(d_fnum);
if (d_release_stmt) {
if (OCIStmtRelease(d_stmt, d_err, (text*)d_stmt_key, d_stmt_keysize, OCI_DEFAULT) != OCI_SUCCESS)
- throw SSqlException("Could not release statement: " + OCIErrStr());
+ throw SSqlException("Could not release statement: " + d_query + string(": ") + OCIErrStr());
d_stmt = NULL;
}
return this;