Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: UTL_FILE replaces 0A by 0D 0A

Re: UTL_FILE replaces 0A by 0D 0A

From: Urs Metzger <urs_at_ursmetzger.de>
Date: Wed, 13 Sep 2006 23:58:21 +0200
Message-ID: <ee9uip$7ps$1@online.de>


Connor McDonald schrieb:

> Kalle Heuwes wrote:

>> Hi, Urs !
>>
>> Unfortunately it also happens with UTL_FILE.put.
>> Besides it is not only appended at the end of a row; it is even
>> replaced in the middle of a string:
>>
>> DECLARE
>> lc_filename VARCHAR2 (100) := 'test.txt';
>> lt_file UTL_FILE.file_type;
>> BEGIN
>> lt_file := UTL_FILE.fopen ('EXPORT', lc_filename, 'w');
>> UTL_FILE.put(lt_file, 'hgfxxx' || CHR(10) || 'xxxgjhg');
>> UTL_FILE.fclose (lt_file);
>> END;
>>
>> Kind regards
>> Kalle

>
> any joy with put_raw ?
Yeah! Joy!!

SQL> declare

   2     text varchar2(20) := 'ab' || chr(10) || 'cd';
   3     file_a utl_file.file_type;
   4     file_b utl_file.file_type;
   5  begin
   6     -- This won't work
   7     file_a := utl_file.fopen('D_TEMP', 'file_a', 'w');
   8     utl_file.put(file_a, text);
   9     utl_file.fclose(file_a);
  10     -- This works! Mode must be 'wb'!
  11     file_b := utl_file.fopen('D_TEMP', 'file_b', 'wb');
  12     utl_file.put_raw(file_b, utl_raw.cast_to_raw(text));
  13     utl_file.fclose(file_b);

  14 end;
  15 /

file_a: 61 62 0D 0A 63 64 0D 0A

file_b: 61 62 0A 63 64

Urs Metzger Received on Wed Sep 13 2006 - 16:58:21 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US