Library /sys$common/syshlp/HELPLIB.HLB  —  RDML72  Statements  ON_ERROR, Examples  C Example
    globalvalue RDB$_LOCK_CONFLICT;
    globalvalue RDB$_DEADLOCK;

    #include <stdio.h>
    DATABASE PERS = FILENAME "PERSONNEL";

    void handle_error()
    {
    if (RDB$STATUS == RDB$_LOCK_CONFLICT)
       printf("database unavailable right now\n");
          else
             {
             printf("Unexpected Error, Application Terminating\n");
             RDML$SIGNAL_ERROR(RDB$MESSAGE_VECTOR);
             }
       return;
    }

    void access_employees()
    {
    READY PERS
       ON ERROR
          handle_error();
          return;
       END_ERROR;

    START_TRANSACTION READ_WRITE NOWAIT
       RESERVING EMPLOYEES FOR EXCLUSIVE WRITE
       ON ERROR
          handle_error();
          return;
       END_ERROR;

    /* perform some read_write operation on the EMPLOYEES relation */
    printf ("Accessing EMPLOYEES...\n");

    COMMIT;
    FINISH;
    }

    main()
    {
    int i;
    for (i=0; i<=100; i++)
       access_employees();
    }
Close Help