Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

SQL query to get the no. of records deleted

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: SQL query to get the no. of records deleted
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    Post subject: Re: SQL query to get the no. of records deleted
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    Post subject:
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: 205
Location: Bangalore

PostPosted: Fri Jan 25, 2008 6:47 pm    Post subject: Reply to: SQL query to get the no. of records deleted
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us