0

Apex version: 22.2.0 I have an apex application that allows a user to execute a query and then download the result as a csv. The result of the query is stored in a clob column in a table. My download procedure is:

declare
    l_csv CLOB;
    l_context apex_exec.t_context;
    l_export APEX_DATA_EXPORT.t_export;
    v_filename VARCHAR2(64);
    v_sql  varchar2(32000) ;
begin

     v_sql := 'select clob_col from clob_table
     where id = '||:P2_ID||';';
     l_context := apex_exec.open_query_context(
          p_location    => apex_exec.c_location_local_db,
          p_sql_query   => v_sql);
if :P2_FORMAT = 'csv' then
     l_export := apex_data_export.export (
         p_context   => l_context,
         p_format    => apex_data_export.c_format_csv,
         p_file_name => nvl(:P2_FILENAME,'result.csv') );
else
    l_export := apex_data_export.export (
        p_context   => l_context,
        p_format    => apex_data_export.c_format_xlsx,
        p_csv_enclosed_by => '',
        p_file_name => nvl(:P2_FILENAME,'result.xlsx') );
end if;          
     apex_exec.close( l_context );

     apex_data_export.download( p_export => l_export );
      
end;

If I run the query:

select file_id,bytes,blocks,status from dba_data_files;

The csv file it downlaods looks like this:

CLOB_COL
"FILE_ID,BYTES,BLOCKS,STATUS
1,838860800,102400,AVAILABLE
2,1048576000,128000,AVAILABLE
3,2306867200,281600,AVAILABLE
4,104857600,12800,AVAILABLE
5,10737418240,1310720,AVAILABLE
6,10737418240,1310720,AVAILABLE
7,10737418240,1310720,AVAILABLE
8,21474836480,2621440,AVAILABLE
9,10737418240,1310720,AVAILABLE
10,10737418240,1310720,AVAILABLE
"

How can I stop it from including the name of the clob column and also not have it surround the csv with double quotes?

Thanks for your help.

0

Browse other questions tagged or ask your own question.