Q
Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

Invoking a stored procedure from a COBOL program

One user writes, "I am attempting to invoke a stored procedure (SQL) from a COBOL program. The stored procedure returns ONE result set, so the last (meaningful) statement in the stored procedure is OPEN cursor name. Once I issue the CALL in the COBOL program, how do I associate the result set to something meaningful, so that I may issue FETCH statements?" DB2 UDB expert Kent Millligan responds.

I am attempting to invoke a stored procedure (SQL) from a COBOL program. The stored procedure returns ONE result...

set, so the last (meaningful) statement in the stored procedure is OPEN cursor name. Once I issue the CALL in the COBOL program, how do I associate the result set to something meaningful, so that I may issue FETCH statements?

On DB2 UDB for iSeries, stored procedures result sets can only be accessed by clients utilizing the ODBC, JDBC, or CLI programming interfaces. This means High Level Languages (HLL) such as RPG and COBOL cannot fetch the result sets generated by an invoked stored procedure. Your COBOL program could utilize CLI APIs to invoke the stored procedure and process the result set. Another workaround is to use global temporary tables to simulate a stored procedure result set. A global table is used to hold temporary data for a database connection (job) or application. Instead of an SQL procedure returning data via a result set, that same data could be placed in a global temporary table and then the invoking COBOL program would just have to know the name of the temporary table in order to access the result set data.

More on this topic

Visit the ITKnowledge Exchange and get answers to your DB2 questions fast.

Check out this Search400.com Featured Topic: Expert advice on DB2 

Search400.com's targeted search engine: Get relevant information on DB2/400. 

The Best Web Links: Tips, tutorials and more.

 

 

This was last published in September 2005

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

SearchDataCenter

Close