Permalink
Browse files

actually prepare statements

  • Loading branch information...
1 parent f2927e0 commit 9ecbf02253882e031e4b4d4929cfb80ac0b03778 @Habbie Habbie committed Nov 11, 2016
Showing with 11 additions and 5 deletions.
  1. +11 −5 modules/godbcbackend/sodbc.cc
@@ -90,6 +90,7 @@ class SODBCStatement: public SSqlStatement
vector<ODBCParam> d_req_bind;
SSqlStatement* bind(const string& name, ODBCParam& p) {
+ prepareStatement();
d_req_bind.push_back(p);
SQLRETURN result = SQLBindParameter(
d_statement, // StatementHandle,
@@ -109,15 +110,16 @@ class SODBCStatement: public SSqlStatement
return this;
}
- SSqlStatement* bind(const string& name, bool value) { return bind(name, (uint32_t)value); }
+ SSqlStatement* bind(const string& name, bool value) { prepareStatement(); return bind(name, (uint32_t)value); }
- SSqlStatement* bind(const string& name, long value) { return bind(name, (unsigned long)value); }
+ SSqlStatement* bind(const string& name, long value) { prepareStatement(); return bind(name, (unsigned long)value); }
- SSqlStatement* bind(const string& name, int value) { return bind(name, (uint32_t)value); }
+ SSqlStatement* bind(const string& name, int value) { prepareStatement(); return bind(name, (uint32_t)value); }
- SSqlStatement* bind(const string& name, long long value) { return bind(name, (unsigned long long)value); }
+ SSqlStatement* bind(const string& name, long long value) { prepareStatement(); return bind(name, (unsigned long long)value); }
SSqlStatement* bind(const string& name, uint32_t value) {
+ prepareStatement();
ODBCParam p;
p.ParameterValuePtr = new UDWORD {value};
p.LenPtr = new SQLLEN {sizeof(UDWORD)};
@@ -127,6 +129,7 @@ class SODBCStatement: public SSqlStatement
}
SSqlStatement* bind(const string& name, unsigned long value) {
+ prepareStatement();
ODBCParam p;
p.ParameterValuePtr = new ULONG {value};
p.LenPtr = new SQLLEN {sizeof(ULONG)};
@@ -136,6 +139,7 @@ class SODBCStatement: public SSqlStatement
}
SSqlStatement* bind(const string& name, unsigned long long value) {
+ prepareStatement();
ODBCParam p;
p.ParameterValuePtr = new unsigned long long {value};
p.LenPtr = new SQLLEN {sizeof(unsigned long long)};
@@ -149,7 +153,7 @@ class SODBCStatement: public SSqlStatement
// cerr<<"asked to bind string "<<value<<endl;
if(d_req_bind.size() > (d_parnum+1)) throw SSqlException("Trying to bind too many parameters.");
-
+ prepareStatement();
ODBCParam p;
p.ParameterValuePtr = (char*) new char[value.size()+1];
@@ -166,6 +170,7 @@ class SODBCStatement: public SSqlStatement
SSqlStatement* bindNull(const string& name) {
if(d_req_bind.size() > (d_parnum+1)) throw SSqlException("Trying to bind too many parameters.");
+ prepareStatement();
ODBCParam p;
p.ParameterValuePtr = NULL;
@@ -179,6 +184,7 @@ class SODBCStatement: public SSqlStatement
SSqlStatement* execute()
{
+ prepareStatement();
SQLRETURN result;
// cerr<<"execute("<<d_query<<")"<<endl;
if (d_dolog) {

0 comments on commit 9ecbf02

Please sign in to comment.