Library /sys$common/syshlp/HELPLIB.HLB  —  RDML72  Statements  Context Variable
    A temporary name that identifies a relation in a record stream
    to Oracle Rdb. Once you have associated a context variable with a
    relation, you use the context variable to refer to fields from
    that relation. In this way, Oracle Rdb always knows which field from
    which relation you are referring to.

    You must use a context variable in every data manipulation
    statement and in every data definition statement that uses a
    record selection expression.

    If you are accessing several record streams at once, the context
    variable lets you distinguish between fields from different
    record streams, even if different fields have the same name.

    If you are accessing several record streams at once that consist
    of the same relation and fields within that relation, context
    variables let you distinguish between the two record streams.

1  –  Examples

    The following programs demonstrate the use of the context
    variable "CS" for the CURRENT_SALARY view. These programs:

    o  Use "CS" to qualify field names in the record selection
       expression, printf, and WRITELN statement

    o  Print the employee ID of all the employees who earn more than
       forty thousand dollars

1.1  –  C Example

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

    main()
    {
    READY PERS;
    START_TRANSACTION READ_ONLY;

    FOR CS IN CURRENT_SALARY WITH CS.SALARY_AMOUNT > 40000.00
       printf ("%s\n",CS.EMPLOYEE_ID);
    END_FOR;

    COMMIT;
    FINISH;
    }

1.2  –  Pascal Example

    program context_var (input,output);
    DATABASE PERS = FILENAME 'PERSONNEL';

    begin
    READY PERS;
    START_TRANSACTION READ_ONLY;

    FOR CS IN CURRENT_SALARY WITH CS.SALARY_AMOUNT > 40000.00
       writeln (CS.EMPLOYEE_ID);
    END_FOR;

    COMMIT;
    FINISH;
    end.

2  –  Format

  (B)0context-variable =

  qqqqqqq> identifier qqqq>

2.1  –  Format arguments

    identifier             A valid alphanumeric host language
                           identifier.
Close Help