Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: UTL_FILE replaces 0A by 0D 0A
Maxim Demenko schrieb:
> Urs Metzger schrieb:
> > 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
>
>
You're right, Maxim, 'wb' is new in 10g.
Maybe someone out there has 9.2 on Windows and could do the test, using 'w' instead of 'wb'.
Urs Metzger Received on Thu Sep 14 2006 - 04:52:09 CDT
![]() |
![]() |