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
 
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: 1806
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 Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
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 scheduling between OPC and TWS give u... nsbl IBM Tools 4 Sun Mar 12, 2017 5:35 pm
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm
No new posts Calling procedure with multiple entri... steve-myers PL/I & Assembler 5 Fri Jan 27, 2017 3:33 pm

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