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.
try this:
st.execute();
if (st.fetch())
{
printf("well done!");
}
else
{
printf("sucks again!");
}
> Nicolas Deroche <[email protected]> hat am 26. Juni 2013 um 16:16
> geschrieben:
>
> And the version like this, isn't working either:
> sql.once << "....";
> if(!sql.got_data())
> {
> /// throws
> }
>
>
> 2013/6/26 Nicolas Deroche <[email protected] <mailto:[email protected]> >
> > >
> > Well using the fetch function right after execute is not working either
> >
> > dbs::Server* server = new dbs::Server();
> > soci::statement st =
> > (sql.prepare << "SELECT linkname, name, engine, listening_ip,
> > listening_port, auth_id, auth_pw, max_clients, parent_linkname, childs, id
> > FROM `" << Server::table_name << "` WHERE `linkname`=':ii'",
> > soci::use(linkname, "ii"),
> > soci::into(server->linkname),
> > soci::into(server->name),
> > soci::into(server->engine_type),
> > soci::into(server->listening_ip),
> > soci::into(server->listening_port),
> > soci::into(server->auth_id),
> > soci::into(server->auth_pw),
> > soci::into(server->max_clients),
> > soci::into(server->parent_linkname),
> > soci::into(server->childs),
> > soci::into(server->id));
> > st.execute();
> > st.fetch();
> >
> > if(!st.got_data())
> > {
> > std::cout << "SQL = SELECT linkname, name, engine, listening_ip,
> > listening_port, auth_id, auth_pw, max_clients, parent_linkname, childs, id
> > FROM `" << Server::table_name << "` WHERE `linkname`='" << linkname << "'"
> > << std::endl;
> > delete server;
> > throw Server::does_not_exist();
> >
> > }
> > else
> > {
> > Server::gets().insert({server->linkname, server});
> > server->init_load();
> > return *server;
> > }
> >
> >
> > 2013/6/26 Mateusz Loskot <[email protected] <mailto:[email protected]>
> > >
> > > > > On 26 June 2013 15:02, Nicolas Deroche < [email protected]
> > > > > <mailto:[email protected]> > wrote:
> > > > The query should return only one row, is t really necessary ?
> > > >
> > > Please, check the docs. It's all there what calls are necessary.
> > >
> > > 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]
> > > <mailto:[email protected]>
> > > <https://lists.sourceforge.net/lists/listinfo/soci-users>
> > > > > >
------------------------------------------------------------------------------
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