Skip to content

Instantly share code, notes, and snippets.

@hanielburton
Created May 12, 2023 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanielburton/5992bfb9e0daf3d9e0c832d5ac7c5bb9 to your computer and use it in GitHub Desktop.
Save hanielburton/5992bfb9e0daf3d9e0c832d5ac7c5bb9 to your computer and use it in GitHub Desktop.
export_util is wrapper package around apex_data_export.download to download a file in Oracle APEX
create or replace package export_util as
procedure download_file(
file_name in varchar2
, mime_type in varchar2 default 'application/octet-stream'
, content_blob in blob
, content_disposition in apex_data_export.t_content_disposition default apex_data_export.c_attachment
, stop_apex_engine in boolean default true
);
procedure download_file(
file_name in varchar2
, mime_type in varchar2 default 'application/octet-stream'
, content_clob in clob
, content_disposition in apex_data_export.t_content_disposition default apex_data_export.c_attachment
, stop_apex_engine in boolean default true
);
end export_util;
create or replace package body export_util as
procedure download_file(
file_name in varchar2
, mime_type in varchar2 default 'application/octet-stream'
, content_blob in blob
, content_disposition in apex_data_export.t_content_disposition default apex_data_export.c_attachment
, stop_apex_engine in boolean default true
)
is
l_export apex_data_export.t_export := apex_data_export.t_export(
file_name => file_name
, mime_type => mime_type
, content_blob => content_blob
);
begin
apex_data_export.download(
p_export => l_export
, p_content_disposition => content_disposition
, p_stop_apex_engine => stop_apex_engine
);
end download_file;
procedure download_file(
file_name in varchar2
, mime_type in varchar2 default 'application/octet-stream'
, content_clob in clob
, content_disposition in apex_data_export.t_content_disposition default apex_data_export.c_attachment
, stop_apex_engine in boolean default true
)
is
l_export apex_data_export.t_export := apex_data_export.t_export(
file_name => file_name
, mime_type => mime_type
, as_clob => true
, content_clob => content_clob
);
begin
apex_data_export.download(
p_export => l_export
, p_content_disposition => content_disposition
, p_stop_apex_engine => stop_apex_engine
);
end download_file;
end export_util;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment