SQL$HELP72.HLB  —  Select Expressions, Arguments  FETCH
    Syntax options:

       FETCH FIRST limit-expression
       FROM NEXT limit-expression

 The FETCH FIRST clause allows the database programmer to limit the
 results returned from a query expression. The FETCH FIRST clause
 is equivalent to functionality currently supported by the LIMIT TO
 clause. FETCH accepts a numeric value expression which may contain
 arbitrary arithmetic operators, function calls, subselect clauses or
 sequence references. The subselect clauses may not reference columns
 in the outer query as it is evaluated before row processing begins.

    The FETCH NEXT is identical to FETCH FIRST but allows the syntax
    to be more descriptive when coupled with the OFFSET clause.

    If no value expression is provided for FETCH it will default to 1
    row.

    The FETCH clause is not compatible with the LIMIT TO clause.

    The following example uses the FETCH FIRST to find the oldest
    manager in the company. The example uses the DEPARTMENTS table
    to locate the employee id of each manager, and after sorting them
    by their birthday, the oldest manager's name and employee id are
    displayed.

    SQL> -- select the most senior manager
    SQL> select e.last_name, e.first_name, e.employee_id
    cont> from departments d, employees e
    cont> where d.manager_id = e.employee_id
    cont> order by e.birthday
    cont> fetch first row only;
     E.LAST_NAME      E.FIRST_NAME   E.EMPLOYEE_ID
     O'Sullivan       Rick           00190
    1 row selected
    SQL>
Close Help