13.7 DOWNLOADプロシージャ

このプロシージャは、APEX_APPLICATION.STOP_APEX_ENGINEをコールして、データ・エクスポートをダウンロードします。

構文

PROCEDURE DOWNLOAD (
    p_export                IN OUT NOCOPY t_export,
    p_content_disposition   IN t_content_disposition    DEFAULT c_attachment,
    p_stop_apex_engine      IN BOOLEAN                  DEFAULT TRUE );

パラメータ

パラメータ 説明
p_export エクスポートの結果オブジェクト。
p_content_disposition 印刷ドキュメントをダウンロードするか、インラインで表示するかを指定します(「添付」または「インライン」)。
p_stop_apex_engine APEX_APPLICATION.STOP_APEX_ENGINEをコールするかどうか。

DECLARE
    l_context apex_exec.t_context; 
    l_export  apex_data_export.t_export;
BEGIN
    l_context := apex_exec.open_query_context(
        p_location    => apex_exec.c_location_local_db,
        p_sql_query   => 'select * from emp' );

    l_export := apex_data_export.export (
        p_context   => l_context,
        p_format    => apex_data_export.c_format_csv,
        p_file_name => 'employees' );

    apex_exec.close( l_context );

    apex_data_export.download( p_export => l_export );

EXCEPTION
    when others THEN
        apex_exec.close( l_context );
        raise;
END;