Skip to main content

Hi,

I'm trying to understand about SQL cursors.

Are cursor names used at run-time i.e. passed to ODBC/SQL engine or just used internally at compile time to associate various EXEC SQL statements.

What I'm wondering is... If a COBOL program, 'A' calls two other programs, 'B' and 'C', alternately, to fetch rows from tables T1 and T2, can programs B and C use the same cursor name i.e. such that both programs have the same-named open cursor?

I'm asking because I'm switching a system from MF native files to MySQL and I'd like to use copybooks of standard procedures. 

Thanks, Linden.

   

Hi,

I'm trying to understand about SQL cursors.

Are cursor names used at run-time i.e. passed to ODBC/SQL engine or just used internally at compile time to associate various EXEC SQL statements.

What I'm wondering is... If a COBOL program, 'A' calls two other programs, 'B' and 'C', alternately, to fetch rows from tables T1 and T2, can programs B and C use the same cursor name i.e. such that both programs have the same-named open cursor?

I'm asking because I'm switching a system from MF native files to MySQL and I'd like to use copybooks of standard procedures. 

Thanks, Linden.

   

Hi Linden,

Cursor names are used internally by the OpenESQL precompiler and do not mean anything at run-time. The actual code generated will be for that of a dynamic SQL statement which will return a result set to the program and bind the columns to the appropriate host variables.

Cursors cannot be shared between programs. All statements that refer to a particular open cursor must be within the same compiled program.

If you declare and open CURSOR1 in prog1 and then call prog2 which declares and opens CURSOR1 these are treated as two distinct cursors.

So once you open a cursor you must perform all of your row fetches within that same program.

Thanks.


Hi,

I'm trying to understand about SQL cursors.

Are cursor names used at run-time i.e. passed to ODBC/SQL engine or just used internally at compile time to associate various EXEC SQL statements.

What I'm wondering is... If a COBOL program, 'A' calls two other programs, 'B' and 'C', alternately, to fetch rows from tables T1 and T2, can programs B and C use the same cursor name i.e. such that both programs have the same-named open cursor?

I'm asking because I'm switching a system from MF native files to MySQL and I'd like to use copybooks of standard procedures. 

Thanks, Linden.

   

Thanks Chris. Great! That's what I was hoping.