On 26 June 2013 15:35, [email protected]
<[email protected]> wrote:
> st.got_data()  simply returns the current member and doesn't any action.
>
> If your request expects only 1 record returned back, than you are at this
> secanios:
>
> 1.) only st.got_data()  -> false because nothing executed so far
> 2.) st.fetch(); st.got_data() -> false too because fetch() returned true for
> the one record and got_data() still false because it's no bulk.

sql.prepare is dedicated to repeated execution, indeed, but it also work
with single time execution, but it requires explicit fetch(), as here:

sql << "insert into test(val, str) values(12, \'abc\')";
int val;
std::string str="abc";
statement st = (sql.prepare <<
   "select val from soci_test where str=:ii", use(str, "ii"), into(val));
st.execute();
bool g = st.fetch();
assert(g == st.got_data()); // simply check what st.fetch() set in previous call
assert(val == 12);

IMHO, it's just waste of time to prepare if one does not  need to
prepare, but should work.

Best regards,
--
Mateusz  Loskot, http://mateusz.loskot.net

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to