15.35 OPEN_WEB_SOURCE_QUERYファンクション

このファンクションは、Webソース問合せコンテキストを開きます。指定されたWebソースの静的IDに基づいて、FETCH_COLLECTIONデータベース操作に一致する操作が選択されます。

構文

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;

パラメータ

表15-33 OPEN_WEB_SOURCE_QUERYファンクションのパラメータ

パラメータ 説明

p_module_static_id

呼び出すWebソース・モジュールの静的ID。

p_parameters

Webソースに渡されるパラメータ値。

p_filters

Webソースに渡されるフィルタ。

p_order_bys

Webソースに渡されるORDER BY式。

p_columns

Webソースから選択される列。

p_first_row

Webソースからフェッチする最初の行。

p_max_rows

Webソースからフェッチする行の最大数。

p_external_filter_expr

1:1で外部Webサービスに渡されるフィルタ式。使用されている実際のWebサービスに依存します。

p_external_order_by_expr

1:1で外部Webサービスに渡されるORDER BY式。使用されている実際のWebサービスに依存します。

p_total_row_count

総行数を求めるかどうか(「すべての行のフェッチを許可」属性が「はい」に設定されている場合にのみサポートされます)。

戻り値

Webソース問合せのカーソルを表すコンテキスト・オブジェクト

次の例では、URLエンドポイントhttps://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojsonに基づいて、静的IDがUSGSのWebソース・モジュールが共有コンポーネントに作成されていることを前提としています。この例では、RESTサービスを呼び出し、結果セットを出力しています。このサンプル・コードは、プラグイン内やPL/SQL実行リージョン内で使用できます。

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;