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 Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am


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