Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Return Result Set from RPG output parameter

Posted on 2006-07-17
6
Medium Priority
?
2,240 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 400 total points
ID: 17128425
not sure about RPG but you can surely do this using Java stored procedure.
0
 
LVL 18

Expert Comment

by:Dave Ford
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 1600 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
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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 (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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Screencast - Getting to Know the Pipeline

916 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