HELPLIB.HLB  —  RDML72  Statements  MIN
    Returns the lowest value for a value expression for all records
    specified by a record selection expression.

1  –  Examples

    The following programs demonstrate the use of the MIN function in
    an assignment statement. These programs:

    o  Store a literal value into all fields for a record in the JOBS
       relation, except the field MINIMUM_SALARY

    o  Cross JOBS over itself

    o  Use the MIN function to compute the lowest salary in the
       existing JOBS records for which the wage class is "1"

    o  Assign this computed value to the record currently being
       stored

    Note that the C program uses the pad_string function to read
    in the values for the STORE statement. This function pads the
    values stored in each field with the correct number of trailing
    blanks to ensure that the length of the values stored match the
    text size of the field. For more information on pad_string, see
    Appendix B of the "RDML Reference Manual".

1.1  –  C Example

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

    DECLARE_VARIABLE min SAME AS PERS.JOBS.MINIMUM_SALARY;

    extern void pad_string();
    main()
    {
    READY PERS;
    START_TRANSACTION READ_WRITE;

    GET
      min = MIN J2.MINIMUM_SALARY OF J2 IN JOBS
            WITH J2.WAGE_CLASS = "1";
    END_GET;

    STORE J IN JOBS USING
        pad_string ("SWPR", J.JOB_CODE, sizeof(J.JOB_CODE));
        pad_string ("1", J.WAGE_CLASS, sizeof(J.WAGE_CLASS));
        pad_string ("Sweeper", J.JOB_TITLE, sizeof(J.JOB_TITLE));
        J.MAXIMUM_SALARY = 10000.00;
        J.MINIMUM_SALARY = min;
    END_STORE;

    ROLLBACK;
    FINISH;
    }

1.2  –  Pascal Example

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

    DECLARE_VARIABLE mini SAME AS PERS.JOBS.MINIMUM_SALARY;

    begin
    READY PERS;
    START_TRANSACTION READ_WRITE;

    GET
      mini = MIN J2.MINIMUM_SALARY OF J2 IN JOBS
             WITH J2.WAGE_CLASS = '1';
    END_GET;

    STORE J IN JOBS USING
        J.JOB_CODE := 'SWPR';
        J.WAGE_CLASS := '1';
        J.JOB_TITLE := 'Sweeper';
        J.MINIMUM_SALARY := mini;
        J.MAXIMUM_SALARY := 10000.00;
    END_STORE;

    ROLLBACK;
    FINISH;
    end.

2  –  Format

  (B)0
  qq> MIN qqqqqqqqqqqqqwqq>qqqqqqqqqqqqqqqqqwqqqqqqqqqqqqqqqqqqqqqk
                       mqq> handle-options qj                     x
                                                                  x
  lqqqqqqqqqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
  x
  mqqqqqqqq> value-expr  qqqqqq>  OF  qqqqqq>     rse   qqqqqqqqqq>

  (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