Solved

Return Result Set from RPG output parameter

Posted on 2006-07-17
6
2,031 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: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 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 our DevOps Teams Maximize Uptime

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

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 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