15.35 OPEN_WEB_SOURCE_QUERY Function
This function opens a Web Source query context. Based on the provided web source static ID, the operation matched to the FETCH_COLLECTION
database operation will be selected.
Syntax
FUNCTION OPEN_WEB_SOURCE_QUERY(
p_module_static_id IN VARCHAR2,
p_parameters IN t_parameters DEFAULT c_empty_parameters,
--
p_filters IN t_filters DEFAULT c_empty_filters,
p_order_bys IN t_order_bys DEFAULT c_empty_order_bys,
p_columns IN t_columns DEFAULT c_empty_columns,
--
p_first_row IN PLS_INTEGER DEFAULT NULL,
p_max_rows IN PLS_INTEGER DEFAULT NULL,
--
p_external_filter_expr IN VARCHAR2 DEFAULT NULL,
p_external_order_by_expr IN VARCHAR2 DEFAULT NULL,
p_total_row_count IN BOOLEAN DEFAULT FALSE )
RETURN t_context;
Parameters
Table 15-33 OPEN_WEB_SOURCE_QUERY Function Parameters
Parameter | Description |
---|---|
|
Static ID of the web source module to invoke. |
|
Parameter values to be passed to the web source. |
|
Filters to be passed to the web source. |
|
Order by expressions to be passed to the web source. |
|
Columns to be selected from the web source. |
|
First row to be fetched from the web source. |
|
Maximum amount of rows to be fetched from the web source. |
|
Filter expression to be passed 1:1 to the external web service. Depends on the actual web service being used. |
|
Order by expression to be passed 1:1 to the external web service. Depends on the actual web service being used. |
|
whether to determine the total row count (only supported when the |
Returns
The context object representing a "cursor"
for the web source query
Example
The following example assumes a Web Source module with the static ID "USGS"
to be created in Shared Components, based on the URL endpoint https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson
. The example invokes the REST service and prints out the result set. This example code could be used within a plug-in or within a "Execute PL/SQL"
region.
declare
l_context apex_exec.t_context;
l_filters apex_exec.t_filters;
l_columns apex_exec.t_columns;
l_row pls_integer := 1;
l_magidx pls_integer;
l_titidx pls_integer;
l_plcidx pls_integer;
l_timidx pls_integer;
l_ididx pls_integer;
begin
l_context := apex_exec.open_web_source_query(
p_module_static_id => 'USGS',
p_max_rows => 1000 );
l_titidx := apex_exec.get_column_position( l_context, 'TITLE' );
l_magidx := apex_exec.get_column_position( l_context, 'MAG' );
l_plcidx := apex_exec.get_column_position( l_context, 'PLACE' );
l_timidx := apex_exec.get_column_position( l_context, 'TIME' );
l_ididx := apex_exec.get_column_position( l_context, 'ID' );
while apex_exec.next_row( l_context ) loop
htp.p( 'ID: ' || apex_exec.get_varchar2( l_context, l_ididx ) );
htp.p( 'MAG: ' || apex_exec.get_varchar2( l_context, l_magidx ) );
htp.p( 'PLACE: ' || apex_exec.get_varchar2( l_context, l_plcidx ) );
htp.p( 'TITLE: ' || apex_exec.get_varchar2( l_context, l_titidx ) );
htp.p( 'TIME: ' || apex_exec.get_varchar2( l_context, l_timidx ) );
end loop;
apex_exec.close( l_context );
exception
when others then
apex_exec.close( l_context );
raise;
end;
Parent topic: APEX_EXEC