The FIRST clause specifies the maximum number of records in a record stream formed by a record selection expression.
1 – 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.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; }
1.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.
2 – Format
(B)0[mfirst-clause = qqqqqq> [4mFIRST[m qqqq> value-expr qqqq>
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.