Skip to main content

I am adding Embedded SQL to my programs, and I was wondering how I would setup the Declaratives Section of the COBOL program to use the Embedded SQL Cursors instead of the COBOL Files?

Do I even need that section any longer when using Embedded SQL?

I am adding Embedded SQL to my programs, and I was wondering how I would setup the Declaratives Section of the COBOL program to use the Embedded SQL Cursors instead of the COBOL Files?

Do I even need that section any longer when using Embedded SQL?

The Declaratives section is only used to trap COBOL File I-O errors and does not apply to embedded SQL.

When using embedded SQL you can use a similar mechanism known as the WHENEVER statement.

Please see the docs here

An example would be:

EXEC SQL WHENEVER sqlerror PERFORM errormessage1 END-EXEC

If you place this before all of your SQL statements then anytime an error occurs on a SQL statement
the paragraph called errormessage1 would be performed.
Within this paragraph you could check the specifc SQLCODE value to determine the exact error.