VMS Help  —  RDML72  Statements  TOTAL
    Returns the sum of the values specified by a record selection
    expression. The value expression must be a numeric data type.

1  –  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.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;
    }

1.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.

2  –  Format

  (B)0 q> TOTAL qqqqqwq>qqqqqqqqqqqqqqqqqqwqqqqqqqqqqqqqqqqqqqqqqk
                 mq> handle-options qqj                      x
                                                             x
  lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqqqqqqqqqqqqqqqqj
  x
  mqq>  value-expr  qqqqqq>  OF  qqqqqq>   rse   qqqqqqqqqqqq>

  (B)0handle-options =

  q> ( qwqqqqqq>  REQUEST_HANDLE  qqqqq>  var qqqqqqqqwq> ) q>
        tqqqqqq> TRANSACTION_HANDLE qqq>  var qqqqqqqqu
        mqqqqqq> REQUEST_HANDLE q> var q> , qqqqqqqk  x
          lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj  x
          mqqqq> TRANSACTION_HANDLE q> var qqqqqqqqqqqj

2.1  –  Format arguments

    value-expr             A value expression. A symbol or a string
                           of symbols used to calculate a value. When
                           you use a value expression in a statement,
                           Oracle Rdb calculates the value associated
                           with the expression and uses that value
                           when executing the statement.

    rse                    A record selection expression. A phrase
                           that defines specific conditions that
                           individual records must meet before
                           Oracle Rdb includes them in a record stream.

    handle-options         A request handle, a transaction handle, or
                           both.

    REQUEST_HANDLE var     The REQUEST_HANDLE keyword followed by a
                           host language variable. A request handle
                           identifies a compiled Oracle Rdb request.
                           If you do not supply a request handle
                           explicitly, RDML associates a unique
                           request handle for the compiled request.

    TRANSACTION_HANDLE     The TRANSACTION_HANDLE keyword followed by
    var                    a host language variable. A transaction
                           handle identifies a transaction. If
                           you do not supply a transaction handle
                           explicitly, RDML uses the default
                           transaction handle.
Close Help