Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: images in oracle
On Thu, 13 Jan 2000 14:39:47 GMT, vervecken_at_my-deja.com wrote:
>I'm currently building a database that contains images. These images are
>stored as BLOB's.
>The database is to be accessed by a PL-SQL cartridge that will allow the
>user to see the images on a browser.
>
>My questions:
>
>Is it possible to this command: htp.img('directory/nameofpicture'), but
>instead of hardcoding the name and location of the image, using a
>variable that refers to the BLOB?
>The image itself is an actual part of the database. It does not exist as
>a seperate file on the disk.
Sure is. You will want to write a procedure that prints the blob given some data that tell it what blob you want. You will also need the mimetype of the image. Here is an example.
given...
create table images(
id number primary key,
mimetype varchar2(2000),
image blob )
/
you can use the procedure...
create or replace
procedure get_image( p_id number ) as
l_raw raw(4069); l_amt number default 4000; l_off number default 1;
from images where id = p_id )
loop dbms_lob.read( c.image, l_amt, l_off, l_raw ); htp.prn( utl_raw.cast_to_varchar2( l_raw ) ); l_off := l_off+l_amt; l_amt := 4000; end loop; exception when no_data_found then null;
and you would call it like this...
procedure show_image_on_web_page is
l_id number := 123;
begin
htp.img( 'procedure_owner.get_image?p_id=' || l_id );
end show_image_on_web_page;
/
hope this helps
chris.
>
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.
--
Christopher Beck
Oracle Corporation
clbeck_at_us.oracle.com
Reston, VA.
![]() |
![]() |