no. of rows from insert,delete and update



IBM's flagship relational database management system

no. of rows from insert,delete and update

Postby Kal El » Tue Jul 06, 2010 4:25 pm

If I have a cobol program containg insert,delete and update queries for a particular table,
How can i know the no. of modified rows after complete execution of the program?

An update statement can alter multiple rows as well in a single shot, so simply putting a counter each time I get SQLCODE as 0 shall not work.
Kal El
 
Posts: 9
Joined: Mon Jun 21, 2010 1:05 pm
Has thanked: 0 time
Been thanked: 0 time

Re: no. of rows from insert,delete and update

 

Re: no. of rows from insert,delete and update

Postby Lindovaldo » Tue Jul 06, 2010 8:45 pm

If the UPDATE statement is successful, SQLERRD(3) is set to the number of rows that are updated.

*****EXEC SQL INCLUDE SQLCA END-EXEC.
01 SQLCA.
05 SQLCAID PIC X(8).
05 SQLCABC PIC S9(9) COMP-4.
05 SQLCODE PIC S9(9) COMP-4.
05 SQLERRM.
49 SQLERRML PIC S9(4) COMP-4.
49 SQLERRMC PIC X(70).
05 SQLERRP PIC X(8).
05 SQLERRD OCCURS 6 TIMES
PIC S9(9) COMP-4.
05 SQLWARN.
10 SQLWARN0 PIC X.
10 SQLWARN1 PIC X.
10 SQLWARN2 PIC X.
10 SQLWARN3 PIC X.
10 SQLWARN4 PIC X.
10 SQLWARN5 PIC X.
10 SQLWARN6 PIC X.
10 SQLWARN7 PIC X.
05 SQLEXT.
10 SQLWARN8 PIC X.
10 SQLWARN9 PIC X.
10 SQLWARNA PIC X.
10 SQLSTATE PIC X(5).

Ok?
Lindovaldo
 
Posts: 5
Joined: Thu Mar 11, 2010 11:56 pm
Has thanked: 0 time
Been thanked: 0 time

Re: no. of rows from insert,delete and update

Postby Kal El » Wed Jul 07, 2010 5:16 pm

ok so simply displaying SQLERRD I will come to the no. of rows that are affected.
Kal El
 
Posts: 9
Joined: Mon Jun 21, 2010 1:05 pm
Has thanked: 0 time
Been thanked: 0 time

Re: no. of rows from insert,delete and update

Postby GuyC » Wed Jul 07, 2010 6:43 pm

Kal El wrote:ok so simply displaying SQLERRD I will come to the no. of rows that are affected.

... after each sql-statement.
if you want total of program, you need to add them somewhere.
GuyC
 
Posts: 315
Joined: Tue Aug 11, 2009 3:23 pm
Has thanked: 1 time
Been thanked: 4 times

Re: no. of rows from insert,delete and update

Postby dick scherrer » Wed Jul 07, 2010 11:04 pm

Hello,
ok so simply displaying SQLERRD I will come to the no. of rows that are affected.

Keep in mind that you are interested in SQLERRD(3). As GuyC mentioned, you also have to code for totaling.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post