15.6 ADD_ORDER_BYプロシージャ

このプロシージャは、ORDER BYコレクションにORDER BY式を追加します。

構文

procedure add_order_by (
    p_order_bys         in out nocopy t_order_bys,
    p_position          in            pls_integer,
    p_direction         in            t_order_direction default c_order_asc,
    p_order_nulls       in            t_order_nulls     default null );

procedure add_order_by (
    p_order_bys         in out nocopy t_order_bys,
    p_column_name       in            t_column_name,
    p_direction         in            t_order_direction default c_order_asc,
    p_order_nulls       in            t_order_nulls     default null );

パラメータ

表15-4 ADD_ORDER_BYプロシージャのパラメータ

パラメータ 説明

p_order_bys

ORDER BYコレクション。

p_position

指定されたデータソースの列を位置で参照します。

p_column_name

指定されたデータ・ソースの列名または別名を参照します。

p_direction

列を昇順または降順でソートするかどうかを定義します。有効な値はc_order_ascc_order_descです。

p_order_nulls

NULLデータを最下位または最上位にソートするかどうかを定義します。有効な値はNULLc_order_nulls_firstおよびc_order_nulls_lastです。NULLは、ソート方向に基づいた自動処理に使用します。

declare
    l_order_bys   apex_exec.t_order_bys;
    l_context     apex_exec.t_context;
begin
    apex_exec.add_order_by(
        p_order_bys     => l_order_bys,
        p_column_name   => 'ENAME',
        p_direction     => apex_exec.c_order_asc );

   l_context := apex_exec.open_web_source_query(
       p_module_static_id => '{web source module static ID}',
       p_order_bys        => l_order_bys,
       p_max_rows         => 1000 );

       while apex_exec.next_row( l_context ) loop
          -- process rows here ...
       end loop;

   apex_exec.close( l_context );
exception
    when others then
        apex_exec.close( l_context );
raise;
end;