Ask the Expert

RPG fetch statement coding to dynamically call unknown fields and data types

I am writing an RPGLE program that will read a control file that contains the select statement criteria. The program then builds the select statement so that any field(s) within any file on the iSeries could retrieve. How would I code the fetch statement to handle this without knowing the number of fields or data types until execution time?
You would need to use the SQL Descriptor Area to dynamically determine the number and attributes of the columns being returned. SQL Descriptor programming is discussed in the IBM SQL Programming book.

If you find the SQL Descriptor Area processing to be complex, you may want to investigate using the SQL CLI (Call Level Interface) functions in your RPG program.

This was first published in December 2008

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

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
Sort by: OldestNewest

Forgot Password?

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

Your password has been sent to: