Skip to main content

Using DYNAMIC.CBL from \\NETEXPRESS\\Examples\\Net Express IDE\\ODBCESQL as an example, I have written a program to test dynamic SQL against a SQL Server Database.  I was wondering if there is a way to declare more than 1 DYNAMIC_SQL cursor?  

I first coded and tested retrieving data from 1 table using the following cursor:

EXEC SQL
   DECLARE VCURS CURSOR FOR DYNAMIC_SQL
END-EXEC

Then, I added a second cursor to retrieve data from another table in the same database:

EXEC SQL
   DECLARE VCURS CURSOR FOR DYNAMIC_SQL
END-EXEC

EXEC SQL
   DECLARE cursortest CURSOR FOR DYNAMIC_SQL
END-EXEC

However, it fails compile with the following error: "ES0100 Duplicate cursor name: cursortest"

I am using NetExpress 5.1 version f.110.0022 and SQLServer 2012.


#SQLserver
#SQL
#EXECSQLEXECUTE
#cobolnetexpress
#MicroFocusCOBOL

Using DYNAMIC.CBL from \\NETEXPRESS\\Examples\\Net Express IDE\\ODBCESQL as an example, I have written a program to test dynamic SQL against a SQL Server Database.  I was wondering if there is a way to declare more than 1 DYNAMIC_SQL cursor?  

I first coded and tested retrieving data from 1 table using the following cursor:

EXEC SQL
   DECLARE VCURS CURSOR FOR DYNAMIC_SQL
END-EXEC

Then, I added a second cursor to retrieve data from another table in the same database:

EXEC SQL
   DECLARE VCURS CURSOR FOR DYNAMIC_SQL
END-EXEC

EXEC SQL
   DECLARE cursortest CURSOR FOR DYNAMIC_SQL
END-EXEC

However, it fails compile with the following error: "ES0100 Duplicate cursor name: cursortest"

I am using NetExpress 5.1 version f.110.0022 and SQLServer 2012.


#SQLserver
#SQL
#EXECSQLEXECUTE
#cobolnetexpress
#MicroFocusCOBOL
DYNAMIC_SQL is not a keyword, it is just the name of the SQL statement within the declare cursor and this name has to be unique as well as the cursor name. So in your example the second declare should be:
declare cursortest cursor for dynamic_sql_test

Using DYNAMIC.CBL from \\NETEXPRESS\\Examples\\Net Express IDE\\ODBCESQL as an example, I have written a program to test dynamic SQL against a SQL Server Database.  I was wondering if there is a way to declare more than 1 DYNAMIC_SQL cursor?  

I first coded and tested retrieving data from 1 table using the following cursor:

EXEC SQL
   DECLARE VCURS CURSOR FOR DYNAMIC_SQL
END-EXEC

Then, I added a second cursor to retrieve data from another table in the same database:

EXEC SQL
   DECLARE VCURS CURSOR FOR DYNAMIC_SQL
END-EXEC

EXEC SQL
   DECLARE cursortest CURSOR FOR DYNAMIC_SQL
END-EXEC

However, it fails compile with the following error: "ES0100 Duplicate cursor name: cursortest"

I am using NetExpress 5.1 version f.110.0022 and SQLServer 2012.


#SQLserver
#SQL
#EXECSQLEXECUTE
#cobolnetexpress
#MicroFocusCOBOL
Thank you, this was an excellent response!

Using DYNAMIC.CBL from \\NETEXPRESS\\Examples\\Net Express IDE\\ODBCESQL as an example, I have written a program to test dynamic SQL against a SQL Server Database.  I was wondering if there is a way to declare more than 1 DYNAMIC_SQL cursor?  

I first coded and tested retrieving data from 1 table using the following cursor:

EXEC SQL
   DECLARE VCURS CURSOR FOR DYNAMIC_SQL
END-EXEC

Then, I added a second cursor to retrieve data from another table in the same database:

EXEC SQL
   DECLARE VCURS CURSOR FOR DYNAMIC_SQL
END-EXEC

EXEC SQL
   DECLARE cursortest CURSOR FOR DYNAMIC_SQL
END-EXEC

However, it fails compile with the following error: "ES0100 Duplicate cursor name: cursortest"

I am using NetExpress 5.1 version f.110.0022 and SQLServer 2012.


#SQLserver
#SQL
#EXECSQLEXECUTE
#cobolnetexpress
#MicroFocusCOBOL
I have one more question that I think I know the answer to, but, I will ask anyway.

Can the cursor name or statement name be a host variable?

Using DYNAMIC.CBL from \\NETEXPRESS\\Examples\\Net Express IDE\\ODBCESQL as an example, I have written a program to test dynamic SQL against a SQL Server Database.  I was wondering if there is a way to declare more than 1 DYNAMIC_SQL cursor?  

I first coded and tested retrieving data from 1 table using the following cursor:

EXEC SQL
   DECLARE VCURS CURSOR FOR DYNAMIC_SQL
END-EXEC

Then, I added a second cursor to retrieve data from another table in the same database:

EXEC SQL
   DECLARE VCURS CURSOR FOR DYNAMIC_SQL
END-EXEC

EXEC SQL
   DECLARE cursortest CURSOR FOR DYNAMIC_SQL
END-EXEC

However, it fails compile with the following error: "ES0100 Duplicate cursor name: cursortest"

I am using NetExpress 5.1 version f.110.0022 and SQLServer 2012.


#SQLserver
#SQL
#EXECSQLEXECUTE
#cobolnetexpress
#MicroFocusCOBOL
I have one more question that I think I know the answer to, but, I will ask anyway.

Can the cursor name or statement name be a host variable?