Skip to main content

I am using Embedded SQL in Visual COBOL, and I am getting an 19514 error message when fetching the next record. 

My cursor is using a temp table, and during some point in the program, the program updates a different table (that uses the same data as the temp table. Once the table is updated, the program performs the fetching of the next record, and we get that error. 

Any ideas on what would be causing this?

I am using Embedded SQL in Visual COBOL, and I am getting an 19514 error message when fetching the next record. 

My cursor is using a temp table, and during some point in the program, the program updates a different table (that uses the same data as the temp table. Once the table is updated, the program performs the fetching of the next record, and we get that error. 

Any ideas on what would be causing this?

By default, cursors without WITH HOLD specified are closed automatically after a COMMIT is done.

To change this behavior you can set the following SQL directive:

SQL(CLOSE_ON_COMMIT=NO}


By default, cursors without WITH HOLD specified are closed automatically after a COMMIT is done.

To change this behavior you can set the following SQL directive:

SQL(CLOSE_ON_COMMIT=NO}

The "Close on Commit Enabled" is set to False in the DB already.  

Where do you specify WITH HOLD in the Cursor?  Maybe I need to add that?


The "Close on Commit Enabled" is set to False in the DB already.  

Where do you specify WITH HOLD in the Cursor?  Maybe I need to add that?

The CLOSE_ON_COMMIT=NO option to which I am referring is a SQL directive that is to be turned on at the program level, not the database level.

You can add WITH HOLD to your cursor declaration:

EXEC SQL DECLARE my_cursor CURSOR WITH HOLD FOR select-statement


The CLOSE_ON_COMMIT=NO option to which I am referring is a SQL directive that is to be turned on at the program level, not the database level.

You can add WITH HOLD to your cursor declaration:

EXEC SQL DECLARE my_cursor CURSOR WITH HOLD FOR select-statement

Oh! I'm sorry! I misunderstood you! 

I understand now! Thanks! 


Oh! I'm sorry! I misunderstood you! 

I understand now! Thanks! 

I tried both of your suggestions, and neither worked.  I still get the error. 

I am not executing the COMMIT command until the program finishes processing, so I know it is not that. 


I tried both of your suggestions, and neither worked.  I still get the error. 

I am not executing the COMMIT command until the program finishes processing, so I know it is not that. 

Is there a setting or an directive that commits when a record is written to the table?  I removed the commit out of my program to see if that would do anything, and it still wrote all the records and I still got the errors. 


Is there a setting or an directive that commits when a record is written to the table?  I removed the commit out of my program to see if that would do anything, and it still wrote all the records and I still got the errors. 

It sounds like maybe you have AUTOCOMMIT turned on?

See the docs here:

What Visual COBOL product version, database version and platform are you running under?


It sounds like maybe you have AUTOCOMMIT turned on?

See the docs here:

What Visual COBOL product version, database version and platform are you running under?

I have no SQL Directives turned on. 

I am on Visual COBOL 5.0 Version 5.0.00256.

SQL DB version SQL Server Express 2019

Running on Windows 10 

We also use Database Connectors in our programs (not the one I am having this issue with)  - Could that be causing some problem??


I have no SQL Directives turned on. 

I am on Visual COBOL 5.0 Version 5.0.00256.

SQL DB version SQL Server Express 2019

Running on Windows 10 

We also use Database Connectors in our programs (not the one I am having this issue with)  - Could that be causing some problem??

Database Connectors shouldn't cause a conflict with this as they would use separate connections. I would recommend that you open up a ticket with Customer Care so that we can investigate this further. If you put my name in the description then I can have it assigned to me.


Database Connectors shouldn't cause a conflict with this as they would use separate connections. I would recommend that you open up a ticket with Customer Care so that we can investigate this further. If you put my name in the description then I can have it assigned to me.

Thanks! I will do that!


I am using Embedded SQL in Visual COBOL, and I am getting an 19514 error message when fetching the next record. 

My cursor is using a temp table, and during some point in the program, the program updates a different table (that uses the same data as the temp table. Once the table is updated, the program performs the fetching of the next record, and we get that error. 

Any ideas on what would be causing this?

Can you publish more sql code. Normally, there is no problem using fetch and then update a another sql table in the same database.

Are you connecting the database at start and closing by end of the program?

What did you have a text in the message error? 

19514 Cursor is not prepared


Thanks! I will do that!

Just for the sake of completeness, the problem that was found is that a subprogram was being called in-between the fetches that was closing and then reopening the SQL connection. Once this was fixed the -19514 no longer occurred.


Just for the sake of completeness, the problem that was found is that a subprogram was being called in-between the fetches that was closing and then reopening the SQL connection. Once this was fixed the -19514 no longer occurred.

Yes - a subprogram that would open and close the DB was being called from another program that my main program called. 

It closed the DB - causing the cursor in the main program to be closed.