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
 

 

handling result sets in DB2 native stored procedure

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Majid Hussain

New User


Joined: 18 Aug 2007
Posts: 20
Location: Bangalore

PostPosted: Fri Nov 22, 2013 2:20 am    Post subject: handling result sets in DB2 native stored procedure
Reply with quote

Hello

I am writing a DB2 native stored procedure which will

1. get multiple rows from TABLE1
2. for each record fetched, update another table TABLE2
3. for each update, send a row in result set with a success message.

1 and 2 are pretty easy. But for 3, we don't have a table and we cannot open a cursor WITH RETURN.

One solution could be to define a temporary table. Insert all the messages and then open a cursor on the table. I have coded a few COBOL-DB2 stored procedure with very good response times.

I was just wondering if there is another way to achieve this in native stored procedures that I have just started to write.
Back to top
View user's profile Send private message

Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1624
Location: NY,USA

PostPosted: Tue Nov 26, 2013 6:28 am    Post subject:
Reply with quote

If I understood correctly, you can declare 2 cursors instead of working with temp tables,

1) for successful message:

Code:
SELECT 'Successfully updated the row'
from sysibm.sysdummy1

2)For unsuccessful message:

Code:
SELECT 'ERROR updating the table'
from sysibm.sysdummy1


Now open anyone cursor based on the SQLCODE of your update query.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Tue Nov 26, 2013 1:15 pm    Post subject:
Reply with quote

DB2 V11 supports arrays but I don't know much about them yet.
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 Is the 'prompt' data for the DSLIST p... Willy Jensen TSO/ISPF 2 Tue Dec 06, 2016 4:38 am
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts Access SQLCA fields inside a stored p... gangapd DB2 4 Thu Oct 27, 2016 10:20 am
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm
No new posts Is possible to call subprogram from c... cmsmoon COBOL Programming 3 Fri Aug 05, 2016 6:46 pm


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