Receiving result sets in RPG (prior to release 7.1) from an SQL SP

Tags:
i5
RPG
SQL
SQL stored procedures
Stored Procedures
I have read through the IBM manual "Stored Procedures, Triggers, and User-Defined Functions on DB2 Universal Database for iSeries" for information related to returning a result set(s) from a stored procedure into an RPG program. The manual states that a Global Temporary table must be used for this as it cannot access the result set once control has returned back to the RPG. My question is this: If I declare the global temporary table in the stored procedure on the fly, how do I access its contents in the RPG? It seems to me that I would used embedded SQL in the RPG and access the GTT data through a cursor, but how would the cursor definition look in the RPG? Wouldn't the compiler complain that it doesn't have the definition of the global temp table. Please help!

Software/Hardware used:
IBM i5, OS 6.1
ASKED: August 23, 2010  5:45 PM
UPDATED: August 26, 2010  6:23 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.

<i>Wouldn’t the compiler complain that it doesn’t have the definition of the global temp table. </i>

You know the exact format of the GTT since you designed it. If you need the definition for a compiler, then create a temporary version to compile over.

This is no different from any file that must be created dynamically in QTEMP. You create a version in QTEMP and compile interactively, or create a basic CL that controls the format creation and the compile in a single submitted job.

Tom

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following