Escolar Documentos
Profissional Documentos
Cultura Documentos
Home Db2 for z/OS 10.0.0 . . . Displaying SQLCA fields by calling DSNTIAR
Previous Next
You can use the assembler subroutine DSNTIAR to generate the error message text in the
SQLCA.
Suppose you want your DB2® COBOL application to check for deadlocks and timeouts, and you
want to make sure your cursors are closed before continuing. You use the statement
WHENEVER SQLERROR to transfer control to an error routine when your application receives a
negative SQLCODE.
In your error routine, you write a section that checks for SQLCODE -911 or -913. You can
receive either of these SQLCODEs when a deadlock or timeout occurs. When one of these
errors occurs, the error routine closes your cursors by issuing the statement:
An SQLCODE of 0 or -501 resulting from that statement indicates that the close was
successful.
To use DSNTIAR to generate the error message text, first follow these steps:
1. Choose a logical record length (lrecl) of the output lines. For this example, assume lrecl is
72 (to fit on a terminal screen) and is stored in the variable named ERROR-TEXT-LEN.
2. Define a message area in your COBOL application. Assuming you want an area for up to 10
lines of length 72, you should define an area of 720 bytes, plus a 2-byte area that specifies
the total length of the message output area.
01 ERROR-MESSAGE.
Cookie Preferences
02 ERROR-LEN PIC S9(4) COMP VALUE +720.
https://www.ibm.com/support/knowledgecenter/en/SSEPEK_10.0.0/apsg/src/tpc/db2z_scenariodsntiar.html 1/3
9/25/2018 IBM Knowledge Center - A scenario for using DSNTIAR
3. Make sure you have an SQLCA. For this example, assume the name of the SQLCA is SQLCA.
To display the contents of the SQLCA when SQLCODE is 0 or -501, call DSNTIAR after the SQL
statement that produces SQLCODE 0 or -501:
You can then print the message output area just as you would any other variable. Your
message might look like this:
Please note that DISQUS operates this forum. When you sign in to comment, IBM will provide your
email, first name and last name to DISQUS. That information, along with your comments, will be
governed by DISQUS’ privacy policy. By commenting, you are accepting the DISQUS terms of service.
Sign In
Sort by Best
Recommend ⤤ Share
More topics
Cookie Preferences
DSNTIAR
https://www.ibm.com/support/knowledgecenter/en/SSEPEK_10.0.0/apsg/src/tpc/db2z_scenariodsntiar.html 2/3
9/25/2018 IBM Knowledge Center - A scenario for using DSNTIAR
DSNTIAR
Explore, learn and succeed with training on the IBM Skills Gateway
English
Cookie Preferences
https://www.ibm.com/support/knowledgecenter/en/SSEPEK_10.0.0/apsg/src/tpc/db2z_scenariodsntiar.html 3/3