VMS Help  —  RDML72  Statements  Arithmetic Expr
    Use an arithmetic expression to combine value expressions and
    arithmetic operators. When you use an arithmetic expression in
    a statement, Oracle Rdb calculates the value associated with the
    expression and uses that value when executing the statement.
    Therefore, an arithmetic expression must result in a value. If
    either operand of an arithmetic expression is a missing value,
    the resultant value also is a missing value.

1  –  Examples

    The following programs demonstrate the use of the multiplication
    (*) arithmetic operator and the MODIFY statement. These programs
    select the record of an employee in the SALARY_HISTORY relation
    with a specified employee ID and that has no value for SALARY_
    END. The purpose of specifying no value for SALARY_END is to
    ensure that the only salary amount affected is the employee's
    present salary. Next, the programs multiply the employee's
    salary by 1.1 to produce an increase of ten percent in his or
    her salary. The MODIFY statement replaces the old value in this
    employee's SALARY_AMOUNT field with the new value.

1.1  –  C Example

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

    main()
    {
    READY PERS;
    START_TRANSACTION READ_WRITE;

    FOR SH IN SALARY_HISTORY
       WITH SH.EMPLOYEE_ID = "00164"
       AND SH.SALARY_END MISSING
          MODIFY SH USING
             SH.SALARY_AMOUNT = SH.SALARY_AMOUNT * 1.1;
          END_MODIFY;
    END_FOR;

    ROLLBACK;
    FINISH;
    }

1.2  –  Pascal Example

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

    begin
    READY PERS;
    START_TRANSACTION READ_WRITE;

    FOR SH IN SALARY_HISTORY
       WITH SH.EMPLOYEE_ID = '00164'
       AND SH.SALARY_END MISSING
          MODIFY SH USING
             SH.SALARY_AMOUNT := SH.SALARY_AMOUNT * 1.1;
          END_MODIFY;
    END_FOR;

    ROLLBACK;
    FINISH;
    end.

2  –  Format

  (B)0arith-expr =

  qwq> numeric-value    qwqqwqq> + qqwqqwq> numeric-value    qwqqq>
   tq> numeric-host-var qu  tqq> - qqu  tq> numeric-host-var qu
   mq> numeric-db-field qj  tqq> * qqu  mq> numeric-db-field qj
                            mqq> / qqj

2.1  –  Format arguments

    numeric-value          A numeric literal.

    numeric-host-var       A host language variable that holds a
                           numeric value.

    numeric-db-field       A database field (qualified with a context
                           variable) that holds a numeric value.

    + - * /                Arithmetic operators. The following table
                           lists the arithmetic operators and their
                           functions.

     Operator     Function
    --------------------------
     +            Add

     -            Subtract

     *            Multiply

     /            Divide
    --------------------------
Close Help