Connecting Tech Pros Worldwide Help | Site Map

return # of rows updated

Claus Mygind's Avatar
Familiar Sight
 
Join Date: Mar 2008
Posts: 173
#1: May 7 '09
Is it possible to find out how many rows are updated when something like the following code is executed?

Expand|Select|Wrap|Line Numbers
  1. update pSum set hours = 8.0 where empno = 623 and detcode = 'Reg'
mwasif's Avatar
Moderator
 
Join Date: Jul 2006
Location: Pakistan
Posts: 718
#2: May 7 '09

re: return # of rows updated


You can use MySQL C API function mysql_affected_rows().
Claus Mygind's Avatar
Familiar Sight
 
Join Date: Mar 2008
Posts: 173
#3: May 7 '09

re: return # of rows updated


Quote:

Originally Posted by mwasif View Post

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

Expand|Select|Wrap|Line Numbers
  1. char *stmt = "UPDATE products SET cost=cost*1.25 WHERE group=10";
  2. mysql_query(&mysql,stmt);
  3. printf("%ld products updated",
  4.        (long) mysql_affected_rows(&mysql));
  5.  
Of course I used my own data for the update command.
Reply