Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 am
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts Join records from 2 files with No Dup... Poha Eater DFSORT/ICETOOL 22 Sun Aug 27, 2017 10:35 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us