RDOHELP72.HLB  —  ON_ERROR, Example
    This BASIC program uses LIB$MATCH_COND to handle errors that
    occur in the MODIFY statement:

    30
    &RDB& START_TRANSACTION READ_WRITE

    45  !  Input data
        !
        PRINT
        INPUT "enter status code"; STATUS_CODE
        PRINT
        INPUT "enter status name"; STATUS_NAME
        PRINT
        INPUT "enter status type"; STATUS_TYPE

    50 !  Modify the record
       !
    &RDB& FOR W IN WORK_STATUS
    &RDB&      MODIFY W USING
    &RDB&        ON ERROR
                   GOSUB 1000
    &RDB&        END_ERROR
    &RDB&        W.STATUS_CODE = STATUS_CODE;
    &RDB&        W.STATUS_NAME = STATUS_NAME;
    &RDB&        W.STATUS_TYPE = STATUS_TYPE
    &RDB&      END_MODIFY
             PRINT
             PRINT STATUS_CODE, STATUS_NAME, STATUS_TYPE
    &RDB& END_FOR
          GO TO 5000

    1000 MATCH_COND =             &
         LIB$MATCH_COND(RDB$STATUS,RDB$_NOT_VALID)

         SELECT MATCH_COND

         CASE 1
            PRINT "You have entered invalid data.  Try again."
            CALL SYS$PUTMSG(RDB$MESSAGE_VECTOR)
    &RDB&     ROLLBACK
            GOTO 20

         CASE 0
            PRINT "Unknown error"
            CALL SYS$PUTMSG(RDB$MESSAGE_VECTOR)
    &RDB&     ROLLBACK
            GO TO 5000

         END SELECT

         RETURN

    5000
    &RDB&   FINISH
            END

    This excerpt from a BASIC program performs the following actions:

    o  Prompts for input for the MODIFY statement.

    o  Starts a FOR loop.

    o  If an error occurs in the MODIFY statement, the program
       branches to the call to LIB$MATCH_COND. This run-time library
       procedure matches the condition value that Oracle Rdb returns
       to the program (RDB$STATUS) with the condition code RDB$_NOT_
       VALID. If the return status is RDB$_NOT_VALID, the program
       prints the appropriate message and loops back to prompt again.
       If some other error code is detected, "Unknown error" is
       displayed and the program stops.
Close Help