Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 2300
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: 1281
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 DB2 Block insert (-803 Error Handling) NJDevils28 COBOL Programming 5 Mon Nov 11, 2019 7:54 pm
No new posts How to force ISPF to allocate ISPF te... Michele Giannuli TSO/ISPF 9 Thu Sep 12, 2019 2:03 pm
No new posts Procedure Division Section socker_dad COBOL Programming 2 Wed Jun 12, 2019 12:21 am
No new posts How to DEBUG DB2 Stored Procedures Us... thesumitk DB2 0 Mon Jun 03, 2019 8:26 pm
No new posts Cursor result set being updated??? John Poulakos DB2 5 Tue May 28, 2019 10:46 pm

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