Solved

Return Result Set from RPG output parameter

Posted on 2006-07-17
6
2,002 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: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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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 (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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

756 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