Solved

Return Result Set from RPG output parameter

Posted on 2006-07-17
6
1,959 Views
Last Modified: 2008-01-09
I need to use a stored procedure(400 DB2) to take input parameters, run an RPG program, then take an RPG output parameter and display it in a result set.

I can do this with a java program call, or I can even display the RPG output on the iSeries console, but my boss requires that I convert the output to a result set and point a cursor to it.

0
Comment
Question by:servicegroup
6 Comments
 
LVL 7

Accepted Solution

by:
sachinwadhwa earned 100 total points
ID: 17128425
not sure about RPG but you can surely do this using Java stored procedure.
0
 
LVL 18

Expert Comment

by:daveslash
ID: 17134550
You may have more success with your question in the AS/400 topic area:

http://www.experts-exchange.com/Programming/Programming_Platforms/AS400/

0
 
LVL 32

Assisted Solution

by:shalomc
shalomc earned 400 total points
ID: 17142298
In RPG, you have to define an array to contain the result set, populate it, and return it to the caller.

Example from http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/sqlp/rbafyresultsete2.htm

CREATE PROCEDURE prod.rtnclient () LANGUAGE RPGLE  
        EXTERNAL NAME prod.rtnclient GENERAL


ILE RPG source for Stored Procedure prod.rtnclient

DRESULT           DS                  OCCURS(20)                    
D COL1                    1     16A                                
C     1             DO        10            X                 2 0  
C     X             OCCUR     RESULT                                
C                   EVAL      COL1='array result set'              
C                   ENDDO                                          
C                   EVAL      X=X-1
C/EXEC SQL DECLARE C2 CURSOR WITH RETURN TO CLIENT                  
C+ FOR SELECT LSTNAM FROM QIWS.QCUSTCDT FOR FETCH ONLY              
C/END-EXEC                                                          
C/EXEC SQL                                                          
C+  OPEN C2                                                        
C/END-EXEC                                                          
C/EXEC SQL                                                          
C+ SET RESULT SETS FOR RETURN TO CLIENT ARRAY :RESULT FOR :X ROWS,  
C+  CURSOR C2                                                      
C/END-EXEC
C                   SETON                                            LR
C                   RETURN        


The magic is in line SET RESULT SETS

ShalomC
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Author Comment

by:servicegroup
ID: 17147849
I don't know if i graded right. I was trying to split between the two answers.

Unfortunately, neither will work.  

I can already access the RPG programs with a java stored procedure, but the boss doesn't want it done that way.
Also, the RPG guys here say they can make an RPG program to return result sets instead of output parameters, but she won't let me do that either.
She wants me to access current RPG programs with output parameters and convert those parameters into Result Sets.

Thanks for your time though
0
 
LVL 3

Author Comment

by:servicegroup
ID: 17147958
After looking at the RPG code closer, I have an idea.  Can I nest a stored procedure, convert the output to an array and return to the outer procedure a result set of the array?? I am not even sure that I know what I am saying.
0
 
LVL 32

Expert Comment

by:shalomc
ID: 17148099
yes,

you can write a wrapper program in rpg that will call the current rpg programs with output parameters, convert their output to array, and return the array as a result set.

Good thinking!

btw, RPG is acronym for RPG programmer geeks.

ShalomC
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now