If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Getting the Count or Rows Updated

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-17-06, 15:21
stuckonsox stuckonsox is offline
Registered User
 
Join Date: Dec 2004
Posts: 1
Getting the Count or Rows Updated

I am using the Unix db2 command line tool (actually in a shell script).

Is there an option I can turn on that will tell me the number of rows affected by an update statement?


for example my sql would be very basic like:
Code:
update EMAIL_ADDR set NAME_EMAIL_ADDR = 'test2@testdomain.com' where id_email_addr = 200
The info I get back is:
Code:
update EMAIL_ADDR set NAME_EMAIL_ADDR = 'test2@testdomain.com' where id_email_addr = 200
DB20000I  The SQL command completed successfully.

The jist of my shell script is:

Code:
db2 "connect to $DATABASE user $USERID using '$PWD' "
db2 +c -tvf $INFILE | tee $RESULTFILE
Reply With Quote
  #2 (permalink)  
Old 03-17-06, 18:47
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
If you use the -a CLI parm you will get the entire SQLCA. The number of rows affected is in sqlerrd(3).

In a procedure you can use the GET DIAGNOSTICS SQL statement to get the ROW_COUNT into a variable, but I don't think that works in CLI.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On