DBA Tips Archive for Oracle
CR/LF Added to Binary File When Using UTL_FILE.PUT_RAW
by Jeff Hunter, Sr. Database Administrator
Two new procedures: UTL_FILE.PUT_RAW and UTL_FILE.GET_RAW were added in Oracle9i to read/write binary files.
I noticed an error with the UTL_FILE.PUT_RAW procedure while attempting to write a BLOB value to a binary file. But, when the file is closed using UTL_FILE.FCLOSE, <CR> + <LF> is added in the end, which I didn't want because it was originally a binary IMAGE (.GIF) file.
This is a documented bug (Bug:2546782 - UTL_FILE.PUT_RAW WRITES WRONG NUMBER OF BYTES) It has been fixed in 10g. The new file open modes like "RB", "WB", "AB" are introduced. If the binary file is opened in these modes then the <CR> + <LF> characters will not be appended to the file. At the time of this writing, there are no workarounds nor is Oracle considering back-porting a fix for Oracle9i.
Copyright (c) 1998-2016 Jeffrey M. Hunter. All rights reserved.
All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express, prior, written permission. Application to host any of the material elsewhere can be made by contacting me at email@example.com.
I have made every effort and taken great care in making sure that the material included on my web site is technically accurate, but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.
Last modified on
Thursday, 15-Mar-2012 13:40:36 EDT
Page Count: 13460