HELPLIB.HLB  —  RDML72  Statements  FIRST Clause, Examples
    The following programs demonstrate the use of the FIRST clause
    and the SORT clause. These programs sort the employees relation
    in ascending order based on EMPLOYEE_ID. The FIRST 50 statement
    creates a record stream that contains the first 50 records from
    the sorted employees relation. These programs print the employee
    ID and last name of these fifty employee records.

1  –  C Example

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

    main ( )
    {
    READY PERS;
    START_TRANSACTION READ_ONLY;

    FOR FIRST 50 E IN EMPLOYEES
       SORTED BY E.EMPLOYEE_ID
          printf ("%s  ",E.EMPLOYEE_ID);
          printf ("%s\n",E.LAST_NAME);
    END_FOR;

    COMMIT;
    FINISH;
    }

2  –  Pascal Example

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

    begin
    READY PERS;
    START_TRANSACTION READ_ONLY;

    FOR FIRST 50 E IN EMPLOYEES
       SORTED BY E.EMPLOYEE_ID
          writeln (E.EMPLOYEE_ID, ' ', E.LAST_NAME);
    END_FOR;

    COMMIT;
    FINISH;
    end.
Close Help