For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!
Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.
Sure, you just need to create the pagination in the PL/SQL code.
Example:
BEGIN ORDS.DEFINE_MODULE( p_module_name => '1 test', p_base_path => '/test/', p_items_per_page => 25, p_status => 'PUBLISHED', p_comments => NULL); ORDS.DEFINE_TEMPLATE( p_module_name => '1 test', p_pattern => 'pagination-cursor', p_priority => 0, p_etag_type => 'HASH', p_etag_query => NULL, p_comments => NULL); ORDS.DEFINE_HANDLER( p_module_name => '1 test', p_pattern => 'pagination-cursor', p_method => 'GET', p_source_type => 'plsql/block', p_items_per_page => 0, p_mimes_allowed => '', p_comments => NULL, p_source => 'declare l_cur sys_refcursor; l_page number := (:page * :numrows) - :numrows; l_rows number := :numrows;begin open l_cur for select o.owner, o.object_name, o.object_id, o.object_type, o.created, o.last_ddl_time, o.timestamp, o.status from all_objects o where o.owner = ''ORDS_METADATA'' order by o.object_type, o.object_name offset l_page rows fetch next l_rows rows only; :ret := l_cur;end;' ); ORDS.DEFINE_PARAMETER( p_module_name => '1 test', p_pattern => 'pagination-cursor', p_method => 'GET', p_name => 'output', p_bind_variable_name => 'ret', p_source_type => 'RESPONSE', p_param_type => 'RESULTSET', p_access_method => 'OUT', p_comments => NULL); COMMIT; END;
BEGIN
ORDS.DEFINE_MODULE(
p_module_name => '1 test',
p_base_path => '/test/',
p_items_per_page => 25,
p_status => 'PUBLISHED',
p_comments => NULL);
ORDS.DEFINE_TEMPLATE(
p_pattern => 'pagination-cursor',
p_priority => 0,
p_etag_type => 'HASH',
p_etag_query => NULL,
ORDS.DEFINE_HANDLER(
p_method => 'GET',
p_source_type => 'plsql/block',
p_items_per_page => 0,
p_mimes_allowed => '',
p_comments => NULL,
p_source =>
'declare
l_cur sys_refcursor;
l_page number := (:page * :numrows) - :numrows;
l_rows number := :numrows;
begin
open l_cur for
select o.owner, o.object_name, o.object_id, o.object_type, o.created, o.last_ddl_time, o.timestamp, o.status
from all_objects o
where o.owner = ''ORDS_METADATA''
order by o.object_type, o.object_name offset l_page rows fetch next l_rows rows only;
:ret := l_cur;
end;'
);
ORDS.DEFINE_PARAMETER(
p_name => 'output',
p_bind_variable_name => 'ret',
p_source_type => 'RESPONSE',
p_param_type => 'RESULTSET',
p_access_method => 'OUT',
COMMIT;
END;
then you simply paginate using ..test/pagination-cursor?page=1&numrows=20, ..test/pagination-cursor?page=2&numrows=20 etc..
Regards
One enhancement would be to user :row_offset and :row_count instead of :page and :numrows as those parameters will be provided by APEX/ORDS out of the box. See: https://docs.oracle.com/en/database/oracle/application-express/21.1/aeutl/how-to-create-RESTful-service-module-example.html#GUID-2617C267-3D76-40C4-9994-F48ED7EEABAB