Home » SQL & PL/SQL » SQL & PL/SQL » UTL_FILE.Put_Line carriage return. (11g R2)
UTL_FILE.Put_Line carriage return. [message #660559] Tue, 21 February 2017 03:25 Go to next message
Manoj.Gupta.91
Messages: 239
Registered: March 2008
Location: Delhi
Senior Member
Hi All,

UTL_FILE.Put_Line automatically enters carriage return character at the end.

(1) If I don't want it to enter carriage return what to do?
(2) If I want it to use my customized record delimeter what to do?

(3) What do you recommend whether to user UTL_FILE buffer or create own buffer.

Thanks & Regards
Manoj

Re: UTL_FILE.Put_Line carriage return. [message #660560 is a reply to message #660559] Tue, 21 February 2017 03:32 Go to previous messageGo to next message
John Watson
Messages: 8922
Registered: January 2010
Location: Global Village
Senior Member
Use UTL_FILE.PUT
Re: UTL_FILE.Put_Line carriage return. [message #660613 is a reply to message #660560] Wed, 22 February 2017 09:38 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
exactly as john said. Say your record terminator is '|' and your record is in the variable string then simply

UTL_FILE.PUT(FILE_HANDLE,STRING||'|');

and no CR will be appended.
Re: UTL_FILE.Put_Line carriage return. [message #660614 is a reply to message #660613] Wed, 22 February 2017 11:24 Go to previous messageGo to next message
Solomon Yakobson
Messages: 3269
Registered: January 2010
Location: Connecticut, USA
Senior Member
Bill B wrote on Wed, 22 February 2017 10:38

and no CR will be appended.
You can do that until buffer size is reached - then you are stuck and will be forced to add EOL no matter what. So best you can do this way is creating file < 32K in size with EOL at the end. Not using EOL implies binary file and needs to be open in WB mode.

SY.
Re: UTL_FILE.Put_Line carriage return. [message #661162 is a reply to message #660614] Thu, 09 March 2017 09:40 Go to previous messageGo to next message
Manoj.Gupta.91
Messages: 239
Registered: March 2008
Location: Delhi
Senior Member
Hi All,

Just to add.

I used CHR(13) || CHR(10) for CRLF new line character in UTL_FILE.Put. I also used 32700 buffer size.

One more thing to add we need to flush every time while writing using UTL_FILE.Put otherwise it does not flush all the written data to file.
If we don't flush file may be improperly written. There will be records which are not actually written to file.

Thanks & Regards
Manoj
Re: UTL_FILE.Put_Line carriage return. [message #661164 is a reply to message #661162] Thu, 09 March 2017 11:25 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
If you use FCLOSE the file will be flushed. If you are leaving the utl_file open then you you have to issue a flush command
Re: UTL_FILE.Put_Line carriage return. [message #661221 is a reply to message #661164] Sat, 11 March 2017 02:43 Go to previous message
Manoj.Gupta.91
Messages: 239
Registered: March 2008
Location: Delhi
Senior Member
I faced this issue even if I've closed file using FCLOSE function. File was not completely flushed.
Previous Topic: Assistance in Query Construction
Next Topic: Query Help
Goto Forum:
  


Current Time: Fri Mar 29 08:42:52 CDT 2024