Skip to content

Instantly share code, notes, and snippets.

@jon-dixon
Created December 17, 2022 19:12
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 jon-dixon/1f4cbe1d501cf8a2d70465ae56a057c0 to your computer and use it in GitHub Desktop.
Save jon-dixon/1f4cbe1d501cf8a2d70465ae56a057c0 to your computer and use it in GitHub Desktop.
ARCS Upload File PL/SQL Block
DECLARE
l_csv_clob CLOB;
l_csv_blob BLOB;
l_file_name VARCHAR2(100);
lc_arcs_base_url CONSTANT VARCHAR2(100) := 'https://<baseURL>/';
BEGIN
-- Build a CLOB containing the CSV data (your code will be different).
l_csv_clob := TO_CLOB('Column1,Column2,Column3,Column4' || chr(10));
l_csv_clob := l_csv_clob || TO_CLOB('203-22201'||','||'A200'||','||'100'||','||'12/5/2022');
-- Convert file content from a CLOB to a BLOB
l_csv_blob := apex_util.clob_to_blob(p_clob => l_csv_clob);
-- Build the filename that will be created on the ARCS file system.
l_file_name := 'JD_CR_'||TO_CHAR(CURRENT_DATE,'YYYYMMDD_HH24MISS')||'.csv';
-- Call API to Call ARCS Upload REST Service to upload the file to the ARCS file system.
arcs_utl_pk.upload_file
(p_base_url => lc_arcs_base_url,
p_file_name => l_file_name,
p_file_path => 'inbox',
p_file_blob => l_csv_blob);
dbms_output.put_line('File ['||l_file_name||'] Uploaded to ARCS');
EXCEPTION WHEN OTHERS THEN
dbms_output.put_line('Error Uploading file to ARCS ['||SQLERRM||']');
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment