Q

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

On the AS/400 in DB2 it may be necessary to make a RPG program that calls select statements with unknown data and fields. SQL Descriptor Area processing or SQL CLI can provide a solution to programmers in need.

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 last published in December 2008

Dig Deeper on DB2 UDB (universal databases)

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

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

Please create a username to comment.

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close