Code: Select all
string a, b, c;
Statement stmt = (session << "SELECT a,b,c FROM MyTable WHERE a='value';"
, into(a), into(b), into(c)
while (!stmt.done() && stmt.execute() == 1)
// use a, b and c here
while loops are quite common in the samples. I took the execute call also into the loop condition to detect if execute indeed returned a valid row. As specified the result should be 1 in this case (because limit is 1), and I truely expect that the result is 0 if execute can't fetch valid data. But indeed the result is always 1. This has a very nasty consequence: I get also "something" back if there is no matching row in the table at all. Which values are then stored in the bound variables? Or is this just a bug?
What is the right way to check if returned data are valid or not?
Previously I used the RecordSet class which worked very well in this aspect. The statement class behaves unclear.
(Poco 1.5.0,SQLite, Linux x86_64)