FAQ
This doesn't work, or to be precise doesn't tell me the true no. of affected rows:

The server is 5.0.22 and the problem arises using either MySQL++ 2.1 or 2.2. The statement is a 'multi query' but consists of either use, create, insert, update or delete commands - no selects.

Because of the multi query I have to use this kind of loop:

Query query = m_db->query ();
query << "use db_name;delete from table_name where..."

for (Result result = query.store () ; query.more_results () ; result = query.store_next ())
if (query.success ())
results += m_db->affected_rows (); // Always 0!

Even though I really want to use execute() so I can check the returned ResNSel object - I can't because these are multi-statements.

Shouldn't affected rows be working here? As I said - it (affected_rows) doesn't appear to work when anything is prepended by a use db_statement. Neither does calling the num_rows method of Result.

Anyone else had this? Or does anyone else have any recommendations - I've tried a myriad of things now whilst checking the reference manual and user guide.

Jim Vanns

--
James Vanns
Systems Programmer
Framestore CFC Ltd.

Search Discussions

  • James Vanns at Feb 13, 2007 at 10:05 am
    This doesn't work, or to be precise doesn't tell me the true no. of affected rows:

    The server is 5.0.22 and the problem arises using either MySQL++ 2.1 or 2.2. The statement is a 'multi query' but consists of either use, create, insert, update or delete commands - no selects.

    Because of the multi query I have to use this kind of loop:

    Query query = m_db->query ();
    query << "use db_name;delete from table_name where..."

    for (Result result = query.store () ; query.more_results () ; result = query.store_next ())
    if (query.success ())
    results += m_db->affected_rows (); // Always 0!

    Even though I really want to use execute() so I can check the returned ResNSel object - I can't because these are multi-statements.

    Shouldn't affected rows be working here? As I said - it (affected_rows) doesn't appear to work when anything is prepended by a use db_statement. Neither does calling the num_rows method of Result.

    Anyone else had this? Or does anyone else have any recommendations - I've tried a myriad of things now whilst checking the reference manual and user guide.

    Jim Vanns

    --
    James Vanns
    Systems Programmer
    Framestore CFC Ltd.


    --
    MySQL++ Mailing List
    For list archives: http://lists.mysql.com/plusplus
    To unsubscribe: http://lists.mysql.com/plusplus?unsub=james.vanns@framestore-cfc.com



    --
    James Vanns
    Systems Programmer
    Framestore CFC Ltd.
  • James Vanns at Feb 13, 2007 at 6:27 pm
    Fixed! My bad. This works:

    try {
    bool done = false;
    Query query = m_db->query ();
    query << queue.m_fifo.top ().m_query;

    try {
    for (Result result = query.store () ; !done ; result = query.store_next ()) {
    if (query.success ()) {
    results += m_db->affected_rows ();
    remove = success = true;
    }

    done = !query.more_results ();
    }
    } catch (...) { // Real MySQL++ exceptions caught here.
    } catch (...) { // Real MySQL++ exceptions caught here.

    Jim

    ----- Original Message -----
    From: "James Vanns" <james.vanns@framestore-cfc.com>
    To: plusplus@lists.mysql.com
    Sent: 13 February 2007 10:12:22 o'clock (GMT) Europe/London
    Subject: Affected rows not reported in 2.1 or 2.2?

    This doesn't work, or to be precise doesn't tell me the true no. of affected rows:

    The server is 5.0.22 and the problem arises using either MySQL++ 2.1 or 2.2. The statement is a 'multi query' but consists of either use, create, insert, update or delete commands - no selects.

    Because of the multi query I have to use this kind of loop:

    Query query = m_db->query ();
    query << "use db_name;delete from table_name where..."

    for (Result result = query.store () ; query.more_results () ; result = query.store_next ())
    if (query.success ())
    results += m_db->affected_rows (); // Always 0!

    Even though I really want to use execute() so I can check the returned ResNSel object - I can't because these are multi-statements.

    Shouldn't affected rows be working here? As I said - it (affected_rows) doesn't appear to work when anything is prepended by a use db_statement. Neither does calling the num_rows method of Result.

    Anyone else had this? Or does anyone else have any recommendations - I've tried a myriad of things now whilst checking the reference manual and user guide.

    Jim Vanns

    --
    James Vanns
    Systems Programmer
    Framestore CFC Ltd.


    --
    MySQL++ Mailing List
    For list archives: http://lists.mysql.com/plusplus
    To unsubscribe: http://lists.mysql.com/plusplus?unsub=james.vanns@framestore-cfc.com



    --
    James Vanns
    Systems Programmer
    Framestore CFC Ltd.


    --
    MySQL++ Mailing List
    For list archives: http://lists.mysql.com/plusplus
    To unsubscribe: http://lists.mysql.com/plusplus?unsub=james.vanns@framestore-cfc.com



    --
    James Vanns
    Systems Programmer
    Framestore CFC Ltd.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupplusplus @
categoriesmysql
postedFeb 5, '07 at 5:54p
activeFeb 13, '07 at 6:27p
posts3
users1
websitemysql.com
irc#mysql

1 user in discussion

James Vanns: 3 posts

People

Translate

site design / logo © 2022 Grokbase