Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: images in oracle

Re: images in oracle

From: Christopher Beck <clbeck_at_us.oracle.com>
Date: Thu, 13 Jan 2000 13:52:55 -0500
Message-ID: <k04s7sonf9kfjpe4svf6qt43o7f2h4sjqp@4ax.com>


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;

begin
  for c in ( select *
               from images
              where id = p_id )

  loop
    dbms_lob.open( c.image, dbms_lob.lob_readonly );     owa_util.mime_header( c.mimetype );     begin
      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;

    end;
  end loop;
end get_image;
/

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.



Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Thu Jan 13 2000 - 12:52:55 CST

Original text of this message

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