27.8 ADD_ORDER_BYプロシージャ

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

構文

シグネチャ1
APEX_EXEC.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 )

シグネチャ2

APEX_EXEC.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 )

パラメータ

パラメータ 説明
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;