Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: problem: stored jpeg in database
A copy of this was sent to alfredh <alfredh_at_dbz.com>
(if that email address didn't require changing)
On Mon, 07 Sep 1998 12:40:42 +0800, you wrote:
>Hi,
>
>I hava problem as follow:
>We store jpeg file in table with column as Blob.
>It is ok to insert.....
>but when we load the jpeg out into variable as Blob and convert it to
>RAW, how to print out the RAW data in browser?
>
>Thx,
>Alfred.
>
It would look like this:
create or replace procedure get_image( p_name in varchar2 ) as
l_lob blob; l_amt number default 30; l_off number default 1; l_raw raw(4096);
select image into l_lob
from image where name = p_name; begin loop dbms_lob.read( l_lob, l_amt, l_off, l_raw ); htp.prn( utl_raw.cast_to_varchar2( l_raw ) ); l_off := l_off+l_amt; l_amt := 4096; end loop; exception when no_data_found then NULL;
UTL_RAW is needed to trick the pl/sql web agent into not printing HEX characters (we want it to print the original raw data but all of the htp functions take varchar's -- converting raw to varchar would convert it into HEX, this just takes the raw and says "pretend it is a varchar")....
UTL_RAW is not always installed -- its part of advanced replication and procedure gateways. If you do not have either of these options installed, it won't be there. To install it, simply goto oracle_home/rdbms/admin and look for *raw*. There will be a spec and body. Install them when connected as SYS or INTERNAL using svrmgrl.
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA
--
http://govt.us.oracle.com/ -- downloadable utilities
Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Mon Sep 07 1998 - 12:26:14 CDT