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[m q> [4mTOTAL[m qqqqqwq>qqqqqqqqqqqqqqqqqqwqqqqqqqqqqqqqqqqqqqqqqk mq> handle-options qqj x x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqqqqqqqqqqqqqqqqj x mqq> value-expr qqqqqq> [4mOF[m qqqqqq> rse qqqqqqqqqqqq> (B)0[mhandle-options = q> ( qwqqqqqq> [4mREQUEST_HANDLE[m qqqqq> var qqqqqqqqwq> ) q> tqqqqqq> [4mTRANSACTION_HANDLE[m qqq> var qqqqqqqqu mqqqqqq> [4mREQUEST_HANDLE[m q> var q> , qqqqqqqk x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj x mqqqq> [4mTRANSACTION_HANDLE[m 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.