On Sat, Jun 22, 2013 at 3:57 PM, Vadim Zeitlin <[email protected]> wrote:

> On Sat, 22 Jun 2013 15:49:07 -0600 Jordan Woehr <[email protected]>
> wrote:
>
> JW> However, for inserting I'm having difficulty. What I want to achieve is
> JW> something as follows:
> JW>
> JW> int vals[NUM_VALS];
> JW> statement st = s.prepare << "INSERT INTO table (c0, c1, c2, ...)
> VALUES (";
> JW> for(int i = 0; i < NUM_VALS; ++i)
> JW>     st << vals[i];
> JW> st << ")";
> JW> st.execute();
> JW>
> JW> Is anything like this possible?
>
>  Why not? You just need to postpone the statement construction until after
> you build the full SQL script in this loop. And you can call
> statement::use() in the loop too.
>

Well. That turned out to be really easy. Thanks!

I guess the disconnect for me was

statement st = s.prepare ...;

I didn't realize that the statement object was constructed from
prepare_type. Seems pretty obvious now.
------------------------------------------------------------------------------
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