VMS Help  —  RDML72  Statements  DB Handle, More
    The example program shown here illustrates a problem with RDML. It is
    written in VAX C, and although the precompilation is clean, the C
    compiler gives errors at the READY statement. This problem occurs only
    when the READY statement contains a database handle that is incorrectly
    specified as a variable rather than specified in a DATABASE statement.

    This program works if a database handle specified in one of the database
    statements is used in the READY statement, whether the READY statement
    is used in a function or in a main module.

    #include stdio
    DATABASE first_db = FILENAME 'the_first';
    DATABASE second_db = FILENAME 'the_second';
    main()
    {
    one_ready(first_db);
    one_ready(second_db);
    printf("%d\n",first_db);
    printf("%d\n",second_db);
    START_TRANSACTION READ_WRITE;
    COMMIT;
    }
    one_ready(the_handle)
    unsigned long the_handle;
    {
    READY the_handle ON ERROR printf("an error\n"); END_ERROR;
    return(the_handle);
    }

    The READY statement, as documented in the V3.0, V3.1, and V4.0 Oracle
    Rdb RDML Reference Manual, states that the database handle (or multiple
    database handles) used in the READY statement must be specified in a
    DATABASE statement.  Oracle does not support user-specified database
    handles in RDML; database handles are automatically declared and used
    in RDML as a result of their specification in a DATABASE statement
    (which is really a declaration). This program attempts to use a
    database handle that is declared explicitly (as opposed to being
    specified in a DATABASE statement), and RDML therefore does not
    recognize it as a database handle. Because a READY statement by itself
    is valid, RDML simply recognizes that the READY statement syntax has
    terminated at that point, and so it fails to detect the ON ERROR clause
    later in the same line.  (It assumes that the rest of the line was host
    language syntax.)

    To enable RDML to recognize your database handle, associate a unique
    number with each database handle, and use it to identify which database
    handle to use. The example shown here is a possible approach:

    #include <stdio.h>

    DATABASE first_db = FILENAME 'PERSONNEL';
    DATABASE second_db = FILENAME 'PERSONNEL';

    main()
    {
    one_ready(1);
    one_ready(2);
    printf("%d\n", first_db);
    printf("%d\n", second_db);
    START_TRANSACTION READ_WRITE;
    COMMIT;
    }

    one_ready(int which_handle)
    {
    switch (which_handle)
       {
        case 1:
           READY first_db ON ERROR printf("an error\n"); END_ERROR;
           break;
        case 2:
           READY second_db ON ERROR printf("an error\n"); END_ERROR;
           break;
       }
    }
Close Help