declare f utl_file.file_type; buffe varchar2(30000); offest int := 1; amount int; begin f := utl_file.fopen('TEST', 'aa.sql', 'w', 30000); for x in (select sql_fulltext, last_load_time from v$sql where to_date(last_load_time, 'yyyy-mm-dd/hh24:mi:ss') > trunc(sysdate) order by 2) loop amount := dbms_lob.getlength(x.sql_fulltext); dbms_lob.read(x.sql_fulltext, amount, offest, buffe); utl_file.put_line(f, buffe); end loop; utl_file.fclose(f); end; /