SQL/MX 3.2.1 Programming Manual for C and COBOL (H06.26+, J06.15+)

Exception Handling and Error Conditions
HP NonStop SQL/MX Release 3.2.1 Programming Manual for C and COBOL663854-005
13-20
Special SQL/MX Error Conditions
:hv-msgtext = MESSAGE_TEXT
END-EXEC.
...
DISPLAY "Condition: " i
DISPLAY "Table : " hv-tabname
DISPLAY "Column : " hv-colname
DISPLAY "SQLSTATE : " hv-sqlstate
DISPLAY "SQLCODE : " hv-sqlcode
DISPLAY "MESSAGE : " hv-msgtext
END-PERFORM.
* Process the SQL error
...
1000-GET-DIAGNOSTICS-END.
Special SQL/MX Error Conditions
Lost Open Error (8574)
When an embedded SQL program accesses a table or view by using a DML statement
or an SQL cursor, NonStop SQL/MX opens the table or view and holds it open until the
program stops executing or until the DML statement, if dynamically prepared, is
deallocated. If the DML statement or cursor, or the transaction containing the
statement or cursor, allows concurrent access to the table or view, the program could
lose its open on the table or view to a DDL or SQL utility operation. The DDL or utility
operation invalidates the open held by the program to change the structure of the table
or view and gains exclusive access to the table or view. A program could also lose its
open on a table or view when a network or hardware interruption occurs.
Occurrences of the Lost Open Error
If a DML statement partially modifies a database object (that is, table, view, and so on)
before the open is invalidated, the SQL/MX executor rolls back the changes made by
the statement and returns the Lost Open Error (8574) to the program. For example,
consider an INSERT statement on a table that has an index. The INSERT statement
always modifies the table first before updating the index. If the index is destroyed, the
Lost Open Error occurs.
If a cursor returns one or more rows to the program before the open is invalidated, the
SQL/MX executor returns the Lost Open Error (8574) to the program. If a cursor or
DML statement does not return any rows to the program before the open is invalidated,
the SQL/MX executor retries the cursor or DML statement and then waits for the lock
to be released on the table or view. If the lock is not released before the timeout is
reached, the SQL/MX executor returns the Lost Open Error (8574) to the program.
If the lock is released before the timeout is reached, the SQL/MX executor reopens the
table or view. If reopening the table or view results in a timestamp mismatch, the
SQL/MX executor performs a similarity check of the table or view. If the similarity check
fails (or is disabled), the SQL/MX executor tries to automatically recompile the
statement. If the SQL/MX executor cannot recompile the statement, it returns the Lost