Anda di halaman 1dari 3

9/25/2018 IBM Knowledge Center - A scenario for using DSNTIAR

Home  Db2 for z/OS 10.0.0  . . .  Displaying SQLCA fields by calling DSNTIAR 

Previous Next

A scenario for using DSNTIAR

 Table of contents Change version 


Search in all products

Search in this product... 

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:

EXEC SQL CLOSE cursor-name

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

02 ERROR-TEXT PIC X(72) OCCURS 10 TIMES


INDEXED BY ERROR-INDEX.
77 ERROR-TEXT-LEN PIC S9(9) COMP VALUE +72.

For this example, the name of the message area is ERROR-MESSAGE.

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:

CALL 'DSNTIAR' USING SQLCA ERROR-MESSAGE ERROR-TEXT-LEN.

You can then print the message output area just as you would any other variable. Your
message might look like this:

DSNT408I SQLCODE = -501, ERROR: THE CURSOR IDENTIFIED IN A FETCH OR


CLOSE STATEMENT IS NOT OPEN
DSNT418I SQLSTATE = 24501 SQLSTATE RETURN CODE
DSNT415I SQLERRP = DSNXERT SQL PROCEDURE DETECTING ERROR
DSNT416I SQLERRD = -315 0 0 -1 0 0 SQL DIAGNOSTIC INFORMATION
DSNT416I SQLERRD = X'FFFFFEC5' X'00000000' X'00000000'

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

0 Comments IBM Knowledge Center

Sort by Best
 Recommend ⤤ Share

Nothing in this discussion yet.

✉ Subscribe d Add Disqus to your siteAdd DisqusAdd


🔒 Disqus' Privacy PolicyPrivacy PolicyPrivacy

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

Defining a message output area

Possible return codes from DSNTIAR

 Print this topic


 PDF download page [Beta]
 PDF download section [Beta]
 Help
 Select a product

 Open a ticket and download fixes at the IBM Support Portal


Find a technical tutorial in developerWorks

Find a best practice for integrating technologies in IBM Redbooks

 Explore, learn and succeed with training on the IBM Skills Gateway

Contact Privacy Terms of use Accessibility Feedback Cookie preferences

English 

Cookie Preferences
https://www.ibm.com/support/knowledgecenter/en/SSEPEK_10.0.0/apsg/src/tpc/db2z_scenariodsntiar.html 3/3

Anda mungkin juga menyukai