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: Displaying images from PL/SQL cartridge

Re: Displaying images from PL/SQL cartridge

From: Gerald Kilgus <gerald.kilgus_at_merck.de>
Date: Thu, 21 Oct 1999 10:16:50 +0200
Message-ID: <380ECBF1.50D57E36@merck.de>


You may want to try

 htp.prn(utl_raw.cast_to_varchar2(buffer)) instead of
htp.prn(buffer)

because htp.prn expects a varchar2 parameter.

Cheers
Gerald

tbarry_at_twocoasts.com wrote:

> This is driving me nuts and I'm sure it's caused by something stupid I'm
> missing. I have jpeg images stored in BLOB columns in an 8i database.
> I want to write a plsql procedure (used as a OAS 4.0.7 cartridge) that
> returns an image to the browser. Here's a sample of the code:
>
> procedure display(p_image_id in number) is
>
> lob_loc BLOB;
> buffer RAW(32767);
> amount BINARY_INTEGER := 32767;
> position INTEGER := 1;
> total_size INTEGER := 0;
>
> begin
>
> select asset_content into lob_loc
> from asset_blob
> where asset_blob_id = p_image_id;
>
> -- Set the mime header
> owa_util.mime_header ('image/jpeg', false);
>
> -- Open the lob for read
> dbms_lob.open (lob_loc, DBMS_LOB.LOB_READONLY);
>
> loop
> dbms_lob.read (lob_loc, amount, position, buffer);
> total_size := total_size + amount;
> htp.prn(buffer);
> position := position + amount;
> end loop;
>
> exception when others then
>
> dbms_lob.close(lob_loc);
>
> end;
>
> When I call this thing from the browser I get a broken image display.
> If I view the source, I see an ascii representation of the image
> contents, e.g.:
>
> FFD8FFE000104A46494600010100000100010000FFDB0084... and so on...
>
> All of the data is there; it just isn't being interpreted as an image.
> Any suggestions or insites would be most appreciated.
>
> Thanks,
>
> Tom Barry
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Thu Oct 21 1999 - 03:16:50 CDT

Original text of this message

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