dbTalk Databases Forums  

Re: Nested queries

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss Re: Nested queries in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jonatan Taminau
 
Posts: n/a

Default Re: Nested queries - 10-21-2005 , 08:51 AM






Quote:
Query query = con.query();
ResUse res = query.use("SELECT id,value FROM table");
while
Shouldn't there be a ; at the end of your first query?



--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #2  
Old   
Chris Frey
 
Posts: n/a

Default Re: Nested queries - 10-21-2005 , 09:12 AM






On Fri, Oct 21, 2005 at 12:34:36PM +0200, Mattias Fliesberg wrote:
Quote:
while (Row row = res.fetch_row()) {
string stuff;
string id = (row.at(0)).c_str();
string value = (row.at(1)).c_str();
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 = (row_0.at(0)).c_str();
if (value2.length() > 0)
stuff = value2;
else
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/libstdc++.so.5
#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
Is there an exception being thrown? I'm not sure how it can get into the
destructors at the query_0.use() point.

- Chris


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #3  
Old   
Warren Young
 
Posts: n/a

Default Re: Nested queries - 10-22-2005 , 11:51 PM



Mattias Fliesberg wrote:
Quote:
I'm trying to execute a query, within another queries loop.
The MySQL C API that underlies MySQL++ imposes restrictions on that.
RTFM. You must consume all rows from a SELECT before you can issue
another query on the same connection.

To get around this, you can use separate Connection objects, and get a
Query object from each one.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #4  
Old   
Mattias Fliesberg
 
Posts: n/a

Default Re: Nested queries - 10-24-2005 , 04:15 AM



T2gsIG9mIGNvdXJzZSBpdCBkb2VzLiBCdXQgaG93IGlzIGl0IH NvbHZlZCBpbiBQSFA/Ckkga25v
dyB5b3UgY2FuIGRvIGl0IHRoZXJlLi4uCgpJJ3ZlIHRyaWVkIH RoZSBzZXBlcmF0ZSBjb25uZWN0
aW9uIHNvbHV0aW9uIGJ1dCBpdCBkaWRuJ3QKd29yaywgZ3Vlc3 MgSSdsbCB0cnkgaXQgYWdhaW4u
CgovL01hdHRpYXMKCgpPbiAxMC8yMy8wNSwgV2FycmVuIFlvdW 5nIDxteXNxbHBwQGV0ci11c2Eu
Y29tPiB3cm90ZToKPiBNYXR0aWFzIEZsaWVzYmVyZyB3cm90ZT oKPiA+Cj4gPiBJJ20gdHJ5aW5n
IHRvIGV4ZWN1dGUgYSBxdWVyeSwgd2l0aGluIGFub3RoZXIgcX VlcmllcyBsb29wLgo+Cj4gVGhl
IE15U1FMIEMgQVBJIHRoYXQgdW5kZXJsaWVzIE15U1FMKysgaW 1wb3NlcyByZXN0cmljdGlvbnMg
b24gdGhhdC4KPiBSVEZNLiAgWW91IG11c3QgY29uc3VtZSBhbG wgcm93cyBmcm9tIGEgU0VMRUNU
IGJlZm9yZSB5b3UgY2FuIGlzc3VlCj4gYW5vdGhlciBxdWVyeS BvbiB0aGUgc2FtZSBjb25uZWN0
aW9uLgo+Cj4gVG8gZ2V0IGFyb3VuZCB0aGlzLCB5b3UgY2FuIH VzZSBzZXBhcmF0ZSBDb25uZWN0
aW9uIG9iamVjdHMsIGFuZCBnZXQgYQo+IFF1ZXJ5IG9iamVjdC Bmcm9tIGVhY2ggb25lLgo+Cj4g
LS0KPiBNeVNRTCsrIE1haWxpbmcgTGlzdAo+IEZvciBsaXN0IG FyY2hpdmVzOiBodHRwOi8vbGlz
dHMubXlzcWwuY29tL3BsdXNwbHVzCj4gVG8gdW5zdWJzY3JpYm U6ICAgIGh0dHA6Ly9saXN0cy5t
eXNxbC5jb20vcGx1c3BsdXM/dW5zdWI9bWF0dGlhcy5mbGllc2JlcmdAZ21haWwuY29tCj4KPg o=


Reply With Quote
  #5  
Old   
Chris Frey
 
Posts: n/a

Default Re: Nested queries - 10-24-2005 , 05:52 AM



You could use the query.store() call instead of query.use()... this returns
a Result object instead of a ResUse, storing the results in memory all
at once, just like PHP's mysql_query().

See the docs:
http://tangentsoft.net/mysql++/doc/u...html#id2810307

- Chris

On Mon, Oct 24, 2005 at 11:14:59AM +0200, Mattias Fliesberg wrote:
Quote:
Oh, of course it does. But how is it solved in PHP?
I know you can do it there...

I've tried the seperate connection solution but it didn't
work, guess I'll try it again.

//Mattias


On 10/23/05, Warren Young <mysqlpp (AT) etr-usa (DOT) com> wrote:
Mattias Fliesberg wrote:

I'm trying to execute a query, within another queries loop.

The MySQL C API that underlies MySQL++ imposes restrictions on that.
RTFM. You must consume all rows from a SELECT before you can issue
another query on the same connection.

To get around this, you can use separate Connection objects, and get a
Query object from each one.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...mail (DOT) com


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.