24.31 HAS_MORE_ROWS Function

This function returns whether the data source has more data after fetching p_max_rows. This function only returns a value after the NEXT_ROW loop has finished. Only then we can know that there is more data to fetch than we actually requested.

Syntax

APEX_EXEC.HAS_MORE_ROWS (
    p_context IN t_context )
    return boolean;

Parameters

Table 24-26 APEX_EXEC.HAS_MORE_ROWS Function Parameters

Parameter Description

p_context

Context object obtained with one of the OPEN_ functions.

Returns

TRUE, if there is more data, FALSE otherwise. NULL if no more data detection was requested.

Examples

The following example executes a query, fetches a maximum of 10 rows, and prints the result set. If there are more rows, then a message "has more rows" displays. This example code can be used within an Execute PL/SQL region.

DECLARE
    l_context      apex_exec.t_context;

BEGIN
    l_context := apex_exec.open_query_context(
        p_location          => apex_exec.c_location_local_db,
        p_max_rows          => 10,
        p_sql_query         => 'select * from emp' );

    while apex_exec.next_row( l_context ) loop
        htp.p( 'EMPNO: ' || apex_exec.get_number  ( l_context, 'EMPNO' ) ); 
        htp.p( 'ENAME: ' || apex_exec.get_varchar2( l_context, 'ENAME' ) );
        htp.p( '<br>' );
    END loop;
    IF apex_exec.has_more_rows( l_context ) THEN
        htp.p( 'there are more rows ...' );
    END IF;
    
    apex_exec.close( l_context );
    return;
EXCEPTION
    when others then
        apex_exec.close( l_context );
        raise;    
END;