HELPLIB.HLB  —  RDML72  Statements  MAX  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  –  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;
    }

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.
Close Help