Discussion:
[soci-users] About get_affected_rows with vars
Ignacio El Kadre
2015-01-05 16:58:56 UTC
Permalink
Hi everybody,

I'm not sure if I'm writing my query in the right place. Sorry if I'm not.

I'm checking the included tests, in particular test7:

statement st1 = (sql.prepare <<
"update soci_test set val = val + 1");
st1.execute(false);

assert(st1.get_affected_rows() == 10);

This pass the test. But the following lines doesn't:

int x = 0;

statement st1 = (sql.prepare <<
"update soci_test set val = val + :x", use(x));

x = 1;

st1.execute(false);

assert(st1.get_affected_rows() == 10);


Am I using the statement in the right way?

Best regards.
Ignacio
Ignacio El Kadre
2015-01-05 17:44:00 UTC
Permalink
I was doing it wrong.

This code will pass the test successfully:

int x = 1;

statement st1 = (sql.prepare <<
"update soci_test set val = val + " << x);

st1.execute(false);

assert(st1.get_affected_rows() == 10);

I'm sorry.

Best regards and congratulations for the library.
Post by Ignacio El Kadre
Hi everybody,
I'm not sure if I'm writing my query in the right place. Sorry if I'm not.
statement st1 = (sql.prepare <<
"update soci_test set val = val + 1");
st1.execute(false);
assert(st1.get_affected_rows() == 10);
int x = 0;
statement st1 = (sql.prepare <<
"update soci_test set val = val + :x", use(x));
x = 1;
st1.execute(false);
assert(st1.get_affected_rows() == 10);
Am I using the statement in the right way?
Best regards.
Ignacio
Loading...