i have tried spooling and also using the dbms_lob. still not able to export the clob columns which is having lenght of 45000
below is the code :
spool file header
set head off set verify off set echo off set pages 0 set long 20000 set longc 20000 set lines 32767 set trimspool on set feedback off set termout off
--- util script
SET serveroutput ON
DECLARE
l_file utl_file.file_type;
l_clob CLOB;
l_buffer VARCHAR2(32767);
l_amount binary_integer := 32767;
l_pos INTEGER := 1;
BEGIN
SELECT mo_xml
INTO l_clob
FROM
( SELECT mo_xml, LENGTH(mo_xml) LEN FROM test_xml ORDER BY LEN ASC
)
WHERE rownum =1;
l_file := utl_file.fopen('test', 'TEMP.TXT', 'w', 32767);
LOOP
dbms_lob.read (l_clob, l_amount, l_pos, l_buffer);
utl_file.put(l_file, l_buffer);
utl_file.fflush(l_file);
l_pos := l_pos + l_amount;
END LOOP;
EXCEPTION
WHEN no_data_found THEN
-- Expected end.
IF utl_file.is_open(l_file) THEN
utl_file.fclose(l_file);
END IF;
WHEN OTHERS THEN
IF utl_file.is_open(l_file) THEN
utl_file.fclose(l_file);
END IF;
raise;
END;
/