VMS Help  —  RDML72  Statements  Context Variable, 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  –  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;
    }

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.
Close Help