VMS Help  —  RDML72  Statements  MAX
    Returns the highest value for a value expression for all records
    specified by a record selection expression.

1  –  Examples

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

    o  Declare a host variable, latest_degree

    o  Use the MAX function to compute the highest number stored in
       YEAR_GIVEN in the DEGREES relation

    o  Assign this computed value to the host variable

    o  Print an informational message and the value computed by the
       MAX function

1.1  –  C Example

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

    main()
    {
    DECLARE_VARIABLE latest_degree SAME AS DEGREES.YEAR_GIVEN;

    READY PERS;
    START_TRANSACTION READ_ONLY;

    GET
       latest_degree = MAX D.YEAR_GIVEN OF D IN DEGREES;
    END_GET;

    printf ("Latest Degree was awarded in: %d\n", latest_degree);

    COMMIT;
    FINISH;
    }

1.2  –  Pascal Example

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

    var
    DECLARE_VARIABLE latest_degree SAME AS DEGREES.YEAR_GIVEN;

    begin
    READY PERS;
    START_TRANSACTION READ_ONLY;

    GET
     latest_degree = MAX D.YEAR_GIVEN OF D IN DEGREES;
    END_GET;

    writeln ('Latest Degree was awarded in: ', latest_degree);

    COMMIT;
    FINISH;
    end.

2  –  Format

  (B)0
  q> MAX qqqqqqqqqwq>qqqqqqqqqqqqqqqqqqwqqqqqqqqqqqqqqqqqqqqqqqqqk
                  mq> handle-options qqj                         x
                                                                 x
  lqqqqqqqqqqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
  x
  mqqqqqqqq>  value-expr  qqqq>  OF  qqqq>   rse   qqqqqqqqqqqqq>

  (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