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: to fflush or not to fflush?

Re: utl_file: to fflush or not to fflush?

From: Jonathan Lewis <jonathan_at_jlcomp.demon.co.uk>
Date: Wed, 31 Oct 2001 20:49:01 -0000
Message-ID: <1004561191.23845.1.nnrp-01.9e984b29@news.demon.co.uk>

The package utl_file exists to write text to file, not for handling binary data.

The following is an extract from the definition of the PUT procedure in the script creating the utl_file package:

  /*
  ** PUT - Put (write) text to file
  **
        etc.

You should also note that the definition of the PUT procedure is:

  PROCEDURE put(file IN file_type,

                buffer IN VARCHAR2);

There is no version of PUT which takes a RAW as a parameter.

If you want to write BLOBs, you could start by getting Thomas Kyte's book:

    Expert one-on-one: Oracle
    Wrox Press.

Chapter 18 shows how to do this with C
external procedures, and Chapter 19 does it with Java.

--
Jonathan Lewis
http://www.jlcomp.demon.co.uk

Host to The Co-Operative Oracle Users' FAQ
http://www.jlcomp.demon.co.uk/faq/ind_faq.html

Author of:
Practical Oracle 8i: Building Efficient Databases

Screen saver or Life saver: http://www.ud.com
Use spare CPU to assist in cancer research.

Joost Mulders wrote in message <3BE05033.9832EF95_at_j-mulders.demon.nl>...

>> > I am having a hard time with the code below (8.1.5, solaris). If the
blob being put is > 32768, then the produced filesize is always 32768. The fflush in the loop is needed to write out the complete file. I think that's not what's documented.
>
>It's even worse! The code (with fflush) does not work. fflush generates an
exception 'write error' while flushing the second buffer of 32K. This means that utl_file.put cannot be used for writing more then 32k of binary data!
>
>utl_file.put_line IS able to write more then 32k of data. Of course it puts
a carriage return after each buffer, which defeats the purpose writing of binary data.
>
>I do not agree with the statement that utl_file is not intended for writing
binary data. utl_file.put is IMHO created for that purpose. My idea for writing blobs with utl_file is from an Oracle whitepaper about blobs in 8i. So, even someone within Oracle thinks it is suitable. Unfortunately, the given example wrote only about 1040 bytes of data, thereby giving the assumption that .put can be used for writing binary data AND hiding a bug. That's mean.
>
Received on Wed Oct 31 2001 - 14:49:01 CST

Original text of this message

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