On 28 September 2012 00:57, Mateusz Loskot <[email protected]> wrote:
> On 26 September 2012 17:42, Howard Butler <[email protected]> wrote:
>>
>> I am wondering if the following scenario is possible.
>>
>> std::string query("INSERT INTO MYTABLE (ID, JUNK) VALUES (DEFAULT,
>> :sometext) RETURNING ID")
>> std::string sometext("some text");
>> int id(0);
>>
>> statement st = sql.prepare << query, use(sometext, "sometext"), into(id);
>
> Howard,
>
> I see no reason why it wouldn't be possible.
> I have just committed basic test case for the RETURNING clause to the
> PostgreSQL tests:
>
> void test12()
> {
> {
> session sql(backEnd, connectString);
>
> table_creator_for_test12 tableCreator(sql);
>
> std::vector<long> ids(10);
> for (int i = 0; i != ids.size(); i++)
> {
> long sid(0);
> std::string txt("abc");
> sql << "insert into soci_test(txt) values(:txt) returning
> sid", use(txt, "txt"), into(sid);
> ids[i] = sid;
> }
>
> std::vector<long> ids2(ids.size());
> sql << "select sid from soci_test order by sid", into(ids2);
>
> assert(std::equal(ids.begin(), ids.end(), ids2.begin()));
> }
>
> std::cout << "test 12 passed" << std::endl;
> }
I forgot to include table creator class used in this test case:
struct table_creator_for_test12 : table_creator_base
{
table_creator_for_test12(session & sql)
: table_creator_base(sql)
{
sql << "create table soci_test(sid serial, txt text)";
}
};
Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://ad.doubleclick.net/clk;258768047;13503038;j?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users