Created
December 17, 2022 19:12
-
-
Save jon-dixon/1f4cbe1d501cf8a2d70465ae56a057c0 to your computer and use it in GitHub Desktop.
ARCS Upload File PL/SQL Block
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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