Page 1 of 1

no. of rows from insert,delete and update

PostPosted: Tue Jul 06, 2010 4:25 pm
by Kal El
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.

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

PostPosted: Tue Jul 06, 2010 8:45 pm
by Lindovaldo
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?

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

PostPosted: Wed Jul 07, 2010 5:16 pm
by Kal El
ok so simply displaying SQLERRD I will come to the no. of rows that are affected.

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

PostPosted: Wed Jul 07, 2010 6:43 pm
by GuyC
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.

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

PostPosted: Wed Jul 07, 2010 11:04 pm
by dick scherrer
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.