return # of rows updated

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Claus Mygind
    Contributor
    • Mar 2008
    • 571

    return # of rows updated

    Is it possible to find out how many rows are updated when something like the following code is executed?

    Code:
    update pSum set hours = 8.0 where empno = 623 and detcode = 'Reg'
  • mwasif
    Recognized Expert Contributor
    • Jul 2006
    • 802

    #2
    You can use MySQL C API function mysql_affected_ rows().

    Comment

    • Claus Mygind
      Contributor
      • Mar 2008
      • 571

      #3
      Originally posted by mwasif
      You can use MySQL C API function mysql_affected_ rows().
      I tried running the example in the MySQL Query Browser but it would not execute

      Here is the example your link point to

      Code:
      char *stmt = "UPDATE products SET cost=cost*1.25 WHERE group=10";
      mysql_query(&mysql,stmt);
      printf("%ld products updated",
             (long) mysql_affected_rows(&mysql));
      Of course I used my own data for the update command.

      Comment

      Working...