15.7 DOWNLOAD Procedure

This procedure downloads the data export by calling APEX_APPLICATION.STOP_APEX_ENGINE.

Syntax

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 );

Parameters

Parameter Description
p_export The result object of an export.
p_content_disposition Specifies whether to download the print document or display inline ("attachment" or "inline").
p_stop_apex_engine Whether to call APEX_APPLICATION.STOP_APEX_ENGINE.

Examples

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;