RDOHELP72.HLB  —  ON_ERROR
    Specifies the statement(s) the host language will perform if
    an error occurs during the execution of the associated data
    manipulation statement. The statements can be host language
    statements or Oracle Rdb data manipulation statements.

                                   NOTE

       ON ERROR is supported only for the high-level language
       preprocessors. ON ERROR is not supported for RDO or Callable
       RDO.

1  –  Format

  (B)0ON ERROR qwq> statement qwq> END_ERROR
            mqqqqqqqq<qqqqqj

    statement

    Any valid host language statement or Oracle Rdb data manipulation
    statement. Separate multiple statements with the appropriate
    delimiter or terminator according to the rules of the host
    language.

2  –  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.

3  –  More

    If you have invoked a database, you have the necessary privileges
    to use the ON_ERROR clause.
Close Help