Solved

Return Result Set from RPG output parameter

Posted on 2006-07-17
6
1,970 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 33

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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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 33

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

895 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

18 Experts available now in Live!

Get 1:1 Help Now