VMS Help  —  RDML72  Statements  TOTAL  Examples
    The following programs demonstrate the use of the TOTAL function
    in an assignment statement. These programs:

    o  Use the TOTAL function to compute the total amount budgeted
       for all departments in the DEPARTMENTS relation

    o  Print this computed value

1  –  C Example

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

    DECLARE_VARIABLE all SAME AS PERS.DEPARTMENTS.BUDGET_ACTUAL;
    main()
    {
    READY PERS;
    START_TRANSACTION READ_ONLY;

    GET
        all = TOTAL D.BUDGET_ACTUAL OF D IN DEPARTMENTS;
    END_GET;

    printf ("%f", all);

    COMMIT;
    FINISH;
    }

2  –  Pascal Example

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

    all : double;

    begin
    READY PERS;
    START_TRANSACTION READ_ONLY;

    GET
       all = TOTAL D.BUDGET_ACTUAL OF D IN DEPARTMENTS;
    END_GET;

    writeln (all:10:2);

    COMMIT;
    FINISH;
    end.
Close Help