VMS Help  —  RDML72  Statements  MIN  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  –  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;
    }

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