IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SQL query to get the no. of records deleted


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Cketha
Warnings : 1

New User


Joined: 19 May 2007
Posts: 22
Location: mumbai

PostPosted: Fri Jan 25, 2008 6:17 pm
Reply with quote

I m deleting the rows from a table by firing DELETE QUERY,I will like to know how to get the count of the no. of rows deleted using SQL query.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Jan 25, 2008 6:43 pm
Reply with quote

Cketha wrote:
I m deleting the rows from a table by firing DELETE QUERY,I will like to know how to get the count of the no. of rows deleted using SQL query.


In the SQLCA it is field SQLERRD (3). See the DB2 SQL Reference Manual.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Jan 25, 2008 6:46 pm
Reply with quote

Cketha,
That value is returned when you do the delete, you don't need a separate query.
Back to top
View user's profile Send private message
Ajay Baghel

Active User


Joined: 25 Apr 2007
Posts: 206
Location: Bangalore

PostPosted: Fri Jan 25, 2008 6:47 pm
Reply with quote

SQLERRD(3) diagnostic array contains the no of records deleted/updated/inserted after the query has executed.


-Ajay
Back to top
View user's profile Send private message
vebs

New User


Joined: 27 Oct 2007
Posts: 19
Location: UK

PostPosted: Sun Jan 27, 2008 1:51 am
Reply with quote

In DB2 Version 8, you have a new statement which is GET DIAGNOSTICS. It can be used in application program to give the no. of rows that were updated, inserted, deleted or fetched. You can use it in your application code as follows
Code:

EXEC SQL
   GET DIAGNOSTICS :rcount = ROW_COUNT;


:rcount host variable will give you no. of rows deleted.

- Vaibhav
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 0
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts RC query -Time column CA Products 3
Search our Forums:

Back to Top