Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2004
    Posts
    1

    Unanswered: 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

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •