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: Convert varchar2 -> BLOB

Re: Convert varchar2 -> BLOB

From: Jeremy <newspostings_at_hazelweb.co.uk>
Date: Wed, 11 May 2005 18:27:15 +0100
Message-ID: <MPG.1cec50c481400506989e6c@news.individual.net>


In article <d5tdr1$toa$1_at_news4.zwoll1.ov.home.nl>, Frank van Bortel says...
> > Assume a binary doc exists at www.myhost.com/fred.doc
> > and I want to get this into a BLOB in a PL/SQL procedure - what is the
> > easiest way to get the file content (and you have to accept that the
> > pl/sql proce needs to go an get the doc rathe rthan havie it passed-in
> > somehow).
> >
> > Thanks...
> >
> >
> Sorry - wrong version: I looked at 10...
> No, no experience with this, but such a file - wouldn't
> that be encoded, e.g. BASE64?
>
>

Well the file would exist in its native form....

In fact it would appear that I have a solution to the problem now which surprises me.... it appears that you can do the following:

declare
  x utl_http.html_pieces;
  i number;

  l_blob blob;
  l_tempblob blob;
  l_raw_chunk	raw(2000);

begin
  x := utl_http.request_pieces('http://myserver/test.jpg'
                               , 10000);
  dbms_lob.createtemporary(l_blob, TRUE);   for i in 1..x.count
  loop
    l_raw_chunk := utl_raw.cast_to_raw(x(i));     l_tempblob := l_raw_chunk;
    dbms_lob.writeappend(l_blob,
                         dbms_lob.getlength(l_tempblob), 
                         l_tempblob );

  end loop;
end;

So thanks for your posts on this - any comments on the above approach?

-- 

jeremy
Received on Wed May 11 2005 - 12:27:15 CDT

Original text of this message

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