Handling SQL error codes in Fortran applications

Fortran applications can request more information about SQL error codes by using the DSNTIAR subroutine or issuing a GET DIAGNOSTICS statement.

Procedure

To request more information about SQL errors from Fortran programs, use the following approaches:

  • You can use the subroutine DSNTIR to convert an SQL return code into a text message. DSNTIR builds a parameter list and calls DSNTIAR for you.
    DSNTIAR takes data from the SQLCA, formats it into a message, and places the result in a message output area that you provide in your application program. For concepts and more information on the behavior of DSNTIAR, see Displaying SQLCA fields by calling DSNTIAR.
    DSNTIAR syntax
    DSNTIAR has the following syntax:
    CALL DSNTIR ( error-length, message, return-code )
    DSNTIAR parameters
    The DSNTIR parameters have the following meanings:
    error-length
    The total length of the message output area.
    message
    An output area, in VARCHAR format, in which DSNTIAR places the message text. The first halfword contains the length of the remaining area; its minimum value is 240.
    The output lines of text are put into this area. For example, you could specify the format of the output area as:
    INTEGER   ERRLEN /1320/
    CHARACTER*132 ERRTXT(10)
    INTEGER   ICODE
    ⋮
    CALL DSNTIR ( ERRLEN, ERRTXT, ICODE )
    where ERRLEN is the total length of the message output area, ERRTXT is the name of the message output area, and ICODE is the return code.
    return-code
    Accepts a return code from DSNTIAR.

    An example of calling DSNTIR (which then calls DSNTIAR) from an application appears in the Db2 sample assembler program DSN8BF3, which is contained in the library DSN8D10.SDSNSAMP. See Sample applications supplied with Db2 for z/OS for instructions on how to access and print the source code for the sample program.

  • You can also use the MESSAGE_TEXT condition item field of the GET DIAGNOSTICS statement to convert an SQL return code into a text message. Programs that require long token message support should code the GET DIAGNOSTICS statement instead of DSNTIAR.