View previous topic :: View next topic
|
Author |
Message |
pjnithin
Active User
Joined: 22 Dec 2005 Posts: 116
|
|
|
|
Is there any explicit DB2 command to get the number of rows deleted from a particular table. I don't want to do a select query before running the delete query to get the number of rows that will be deleted. |
|
Back to top |
|
|
VinayCM
New User
Joined: 06 Nov 2007 Posts: 36 Location: Bengaluru
|
|
|
|
Hi,
I think it's stored in SQLERRD if you are in a COBOL-DB2 program and you included SQLCA. Just check it, I'm not sure. |
|
Back to top |
|
|
Srihari Gonugunta
Active User
Joined: 14 Sep 2007 Posts: 295 Location: Singapore
|
|
|
|
The following options can be used for this purpose
1) DELETE FROM EMP WHERE JOB = ’OPERATOR’
If the DELETE is successful, SQLERRD(3) in the SQLCA contains the number of deleted rows.
2) SELECT COUNT(*) INTO :CNT FROM OLD TABLE (DELETE FROM EMP WHERE JOB = ’OPERATOR’);
Select and Delete combined in this case. |
|
Back to top |
|
|
|