38.4 OPEN_QUERY_CONTEXT Function

This function returns an APEX_EXEC query context returning current region data.

This function runs within an autonomous transaction.

Only native regions are supported at this time.

Syntax

FUNCTION APEX_REGION.OPEN_QUERY_CONTEXT (
  p_page_id                IN NUMBER,
  p_region_id              IN NUMBER,
  p_component_id           IN NUMBER    DEFAULT NULL,
  p_view_mode              IN VARCHAR2  DEFAULT NULL,
  --
  p_additional_filters     IN apex_exec.t_filters DEFAULT apex_exec.c_empty_filters,
  p_outer_sql              IN VARCHAR2  DEFAULT NULL,
  --
  p_first_row              IN NUMBER    DEFAULT NULL,
  p_max_rows               IN NUMBER    DEFAULT NULL,
  p_total_row_count        IN BOOLEAN   DEFAULT FALSE,
  p_total_row_count_limit  IN NUMBER    DEFAULT NULL,
  --
  p_parent_column_values IN apex_exec.t_parameters DEFAULT apex_exec.c_empty_parameters )
  RETURN apex_exec.t_context;

Parameters

Table 38-2 OPEN_QUERY_CONTEXT Parameters

Parameter Description
p_page_id ID of the page where the region is on.
p_region_id ID of a specific region to open the query context for.
p_component_id Region component ID to use. For interactive reports and interactive grids this is the saved report ID within the current application page. For JET charts, use the chart series ID.
p_view_mode

The view type available for the report. The values can be APEX_IR.C_VIEW_REPORT, APEX_IR.C_VIEW_GROUPBY, or APEX_IR.C_VIEW_PIVOT.

If p_view is null, it gets the view currently used by the report. If the p_view passed does not exist for the current report, an error is raised.

p_additional_filters Additional filters to apply to the context.
p_outer_sql

Outer SQL query to wrap around the region SQL query. Use #APEX$SOURCE_DATA# to reference the region source (apex_exec.c_data_source_table_name constant).

If this parameter is specified, then the P_COLUMNS parameter has no effect. This parameter overrides CHART, GROUP BY or PIVOT views for interactive reports.

p_first_row Row index to start fetching at. Defaults to 1.
p_max_rows Maximum amount of rows to get. Default unlimited.
p_total_row_count Determines whether to retrieve the total row count. Defaults to false.
p_total_row_count_limit Upper limit of rows to process the query on. This applies to interactive report aggregations or ordering. Default is no limit.
p_parent_column_values For the detail grid in an Interactive Grid Master-Detail relationship. Use this parameter to pass in values for the master-detail parent column(s).

Example

The following example demonstrates how to get the query context for a given saved interactive report on page 1 and print the data out as JSON.

DECLARE
       l_context apex_exec.t_context;
BEGIN
       l_context := apex_region.open_query_context (
              p_page_id => 1,
              p_region_id => 2505704029884282,
              p_component_id => 880629800374638220 );

       apex_json.open_object;
       apex_json.write_context( 'data', l_context );
       apex_json.close_object;
END;