Test insert update success


I have many question to post because I returned to Cobol years later. The most important question regards the database pre-compiler. In particular:

1) With EXEC SQL Can I set isolation level and begin transaction ?

2) How Can I test if an insert or updated does not succeed because of constraints violations?

3) If I set autocommit disabled in SQl properties can I use commit and rollback ?

4) To set a null value it is sufficient move -1 to :name-fileld-null  ?



  • Verified Answer

    Hi Claudio,

    I am assuming that your are using a native code project on Windows and you are using ODBC with OpenESQL, is that correct?

    You can set the isolation level for a transaction in several different ways.
    You can set it using the ISOLATION compiler directive or as part of the BEHAVIOR directive.
    You can also use the EXEC SQL SET TRANSACTION ISOLATION statement.

    Please see the documentation here:

    You might also look at the DECLARE CURSOR as you can set concurrency options directly when declaring the cursor.

    If an insert or update fails then the sqlcode should be set to the appropriate error code and the error message will be placed in the sqlerrmc field of the SQLCA structure.

    If you turn off AUTOCOMMIT then yes, you can use EXEC SQL BEGIN TRANS with ROLLBACK or COMMIT to control your own transactions.

    To set a null value in a column you would move a -1 to the associated null indicator.