List:MySQL++« Previous MessageNext Message »
From:Mattias Fliesberg Date:October 21 2005 10:34am
Subject:Nested queries
View as plain text  

I'm trying to execute a query, within another queries loop.
And it isn't working well. The program dies when I execute use()...

Like this:

Connection con("db", "Host", "User", "Passwd");
Query query = con.query();
ResUse res = query.use("SELECT id,value FROM table");
while (Row row = res.fetch_row()) {
	string stuff;
	string id = (;
	string value = (;
	Query query_0 = con.query();
	ResUse res_0 = query_0.use("SELECT value2 FROM table2 WHERE id=" + id);
	Row row_0 = res_0.fetch_row();
	string value2 = (;
	if (value2.length() > 0)
		stuff = value2;
		stuff = value;
	/* ... */

It dies at "query_0.use(..." with this output from gdb:

#0  0x401e7467 in std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::~basic_string ()
   from /usr/lib/
#1  0x08052bd3 in ~basic_stringbuf (this=0xbffff5d0) at query.h:195
#2  0x08058aeb in ~Query (this=0xbffff580) at main.cpp:45
#3  0x0805837d in main (argc=1, argv=0xbffffd54) at main.cpp:76

Can anybody solve this?

Nested queriesMattias Fliesberg21 Oct
  • Re: Nested queriesChris Frey21 Oct
    • MySQL DevelopmentFabricio Mota22 Oct
  • Re: Nested queriesWarren Young23 Oct
    • Re: Nested queriesMattias Fliesberg24 Oct
      • Re: Nested queriesChris Frey24 Oct
Re: Nested queriesJonatan Taminau21 Oct