Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: OWS: how to retrive image from db?
On Tue, 27 Apr 1999 10:41:40 GMT, klimsamgin <klimsamgin_at_yahoo.com>
wrote:
>Hi!
>
>I've got a web interface to the database
>(OWS on Solaris 2.5, Oracle 7.3) and
>I can see text strings from tables through a browser.
>But in some tables I store gif images in LONG RAW format.
>Is there a way to retrive pictures from database and
>see them in a browser? (A simple one is to store images on
>disk and call them through <img...> tag, but
>the images are already in database.)
You need to send the mime header first before sending the image content, as in:
owa_util.mime_header('image/gif');
open retriveimg; fetch retriveimg into imagebuff; close retriveimg;
As well, prior to printing the raw data, you need to convert it to a string:
htp.prn( utl_raw.cast_to_varchar2(imagebuff));
[From Thomas Kyte: utl_raw may not be installed in your instance. To install, look in $ORACLE_HOME/rdbms/admin for *raw* and install the spec and body using SVRMGRL when connected as INTERNAL or SYS (not as system, not as anyone else, only as INTERNAL or SYS). ]
>
>When I build html page, I use <img src="..."> tag (htp.img)
>to call the picture, where src="/servicename/owa/imageretriver".
>
>procedure imageretriver is
>
> cursor retriveimg is
> select img
> from image
> where n=1;
>
> imagebuff image.img%type;
>
> begin
> open retriveimg;
>
> fetch retriveimg into imagebuff;
>
> close retriveimg;
>
> htp.prn(imagebuff);
> end;
>
>end;
>
>And it works, but in stead of image I've got
>it's hex code (you know, header GIF89 is 47494638396190...).
>
>Thanks.
>
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
Thanks!
Joel
Joel R. Kallman Oracle Service Industries
Columbus, OH http://govt.us.oracle.com jkallman@us.oracle.com http://www.oracle.com