Re: CLOB to file via UTL_FILE

From: Vladimir M. Zakharychev <vladimir.zakharychev_at_gmail.com>
Date: Wed, 24 Dec 2008 08:03:22 -0800 (PST)
Message-ID: <0ce24187-da7b-4187-a1ac-e31bc3195254@z6g2000pre.googlegroups.com>


On Dec 24, 12:30 am, webtourist <webtour..._at_gmail.com> wrote:
> I have large CLOB (XML) (way bigger than 32K) data that has NO
> LINEBREAK/NL.....
>
> I want to write the CLOBs to files.
> Using UTL_FILE...is there anyway  to avoid newline --- so that the
> file size = LOB length ?
>
> If not, is there another option ?
>
> thanks

UTL_FILE.PUT() does not append newline characters, just make sure you do not write more than the buffer size specified to UTL_FILE.FOPEN() without flushing with UTL_FILE.FFLUSH(). For example,

declare
  f UTL_FILE.FILE_TYPE;
  cpos pls_integer := 1;
begin
  f := utl_file.fopen('SOMEDIR', 'somefile.xml', 'w' , 16386);   while cpos < dbms_lob.getlength(:clob) loop     utl_file.put(f,dbms_lob.substr(:clob, 16386, cpos));     cpos := cpos + 16386;
    utl_file.fflush(f);
  end loop;
  utl_file.fclose(f);
end;

Hth,

   Vladimir M. Zakharychev
   N-Networks, makers of Dynamic PSP(tm)    http://www.dynamicpsp.com Received on Wed Dec 24 2008 - 10:03:22 CST

Original text of this message