Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

export clob column with muliple line to csv oracle

User368454Nov 8 2021

I have a requirement to export table with clob column to csv file.
I have created procedure to export that, but the issue here is the clob data spreaded in to multiple rows missing up the table structure on CSV file.
any help to limit the clob data to be written in one filed only.
here is the procedure script
create or replace procedure edm_aiq.xxexportEDM_AIQ_V_DDR_TO_CSV is
file_handle UTL_FILE.file_type;
begin
file_handle := utl_file.fopen('EDM_CSV', 'EDM_AIQ.V_DDR_'||to_char(sysdate,'DDMONYYYY')||'.csv', 'w', 32767);
for rws in (
Select PROJECT,RIG,WELL,WELLBORE,OP_TYPE,CODE,DURATION_HRS,OPERATION,PHASE,SUBCODE,MD_TO,TIME_FROM,TIME_TO,HOUR_SUMMARY_24,REPORT_DATE,OBJECTIVE,OBJECTIVE_CODE,EVENT,WELL_TYPE,RIG_PICKUP_DATE,RIG_RELEASED,RIG_ACCEPT,RIG_ON_LOC,SPUD from EDM_AIQ.V_DDR -- your query here
) loop
utl_file.put_line(file_handle,
rws.PROJECT|| ',' || rws.RIG|| ',' || rws.WELL|| ',' || rws.WELLBORE|| ',' || rws.OP_TYPE|| ',' || rws.CODE|| ',' || rws.DURATION_HRS|| ',' || rws.OPERATION|| ',' || rws.PHASE|| ',' || rws.SUBCODE|| ',' || rws.MD_TO|| ',' || rws.TIME_FROM|| ',' || rws.TIME_TO|| ',' || rws.HOUR_SUMMARY_24|| ',' || rws.REPORT_DATE|| ',' || rws.OBJECTIVE|| ',' || rws.OBJECTIVE_CODE|| ',' || rws.EVENT|| ',' || rws.WELL_TYPE|| ',' || rws.RIG_PICKUP_DATE|| ',' || rws.RIG_RELEASED|| ',' || rws.RIG_ACCEPT|| ',' || rws.RIG_ON_LOC|| ',' || rws.SPUD -- your columns here
);
end loop;
utl_file.fclose(file_handle);
end xxexportEDM_AIQ_V_DDR_TO_CSV;
/

Comments
Post Details
Added on Nov 8 2021
10 comments
3,885 views