  | | | Subject: Re: Issues with multi-queries | Subject: Re: Issues with multi-queries 2007-11-09 - By Warren Young
Back Paul Martin wrote: > 1. Comment out 4 lines starting with 'print_result' in the > 'print_multiple_results' function (to kill screen printing)
You also commented out the Query::more_results() call. That's why it dies the second time around: you must consume all results on a MySQL DB connection before you make another one. Hard limit of the underlying C API, no option to change it. You must consume the results.
I made my own changes to multiquery.cpp, and it works here on both Linux and Windows, built against MySQL 5.0 and MySQL++ svn.
Index: examples/multiquery.cpp =================================================================== --- examples/multiquery.cpp (revision 1814) +++ examples/multiquery.cpp (working copy) @@ -123,10 +123,10 @@ try { // Execute query and print all result sets Result res = query.store(); - print_result(res, 0); - for (int i = 1; query.more_results(); ++i) { + cout << '.' << flush; + while (query.more_results()) { res = query.store_next(); - print_result(res, i); + cout << '.' << flush; } } catch (Exception& err) { @@ -163,16 +163,18 @@
// Set up query with multiple queries. Query query = con.query(); - query << "DROP TABLE IF EXISTS test_table;" << endl << - "CREATE TABLE test_table(id INT);" << endl << - "INSERT INTO test_table VALUES(10);" << endl << - "UPDATE test_table SET id=20 WHERE id=10;" << endl << - "SELECT * FROM test_table;" << endl << - "DROP TABLE test_table" << endl; - cout << "Multi-query: " << endl << query.preview() << endl; + while (1) { + query.reset(); + query << "DROP TABLE IF EXISTS test_table; " << + "CREATE TABLE test_table(id INT); " << + "INSERT INTO test_table VALUES(10); " << + "UPDATE test_table SET id=20 WHERE id=10; " << + "SELECT * FROM test_table; " << + "DROP TABLE test_table";
- // Execute statement and display all result sets. - print_multiple_results(query); + // Execute statement and display all result sets. + print_multiple_results(query); + }
#if MYSQL_VERSION_ID >= 50000 // If it's MySQL v5.0 or higher, also test stored procedures, which
It'll sit there spitting dots out at you until you get quite bored.
-- MySQL++ Mailing List For list archives: http://lists.mysql.com/plusplus To unsubscribe: http://lists.mysql.com/plusplus?unsub=mysql@(protected)
|
|
 |