Home » SQL & PL/SQL » SQL & PL/SQL » displaying images from oracle 8i blob in asp
displaying images from oracle 8i blob in asp [message #38063] Mon, 18 March 2002 00:47 Go to next message
Ruaridh
Messages: 3
Registered: March 2002
Junior Member
Hi,

I'm trying to find out if its realistically possible to display images that are stored in an Oracle 8i database directly onto an asp page.

I have got this far....

1) I have a procedure with which I can sucessfully load a j-peg into a BLOB column.
2) I understand that the Response object has to be set to "image/jpeg" and this asp page will only be able to dispaly an image and nothing else(?)
3) I believe that (unlike SQL server) Oracle cannot manipulate LOB columns directly from SQL, but rather the DBMS_LOB package has to be used in a procedure / function.
4)I have a procedure and a function which can both load my j-peg image into a RAW datatype.

BUT, as usual, I can find very little info. on how to successfully operate these procedures from an asp page.

Has anyone done this?
I'm trying Response.BinaryWrite, is this correct?

I'd really appreciate hearing from anyone who has made this work, or perhaps seeing some code samples.

Thank you.
Ruaridh.
Re: displaying images from oracle 8i blob in asp [message #38064 is a reply to message #38063] Mon, 18 March 2002 01:30 Go to previous messageGo to next message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
here is procedure , change it accordingly

u have to call it like

img src=http://your_server_name/retreiveimage?p_image_name=xyz

hope it helps!!!

create or replace PROCEDURE retreiveimage(p_image_name varchar2) AS
v_lob BLOB;
v_buffer RAW(32767);
v_offset BINARY_INTEGER:=1;
v_buffer_size NUMBER:=32767;
BEGIN
SELECT image INTO v_lob
FROM tbl_images WHERE file_name=p_image_name;
OWA_UTIL.MIME_HEADER('image/gif');
LOOP
DBMS_LOB.READ(v_lob,v_buffer_size,v_offset,v_buffer);
htp.prn(UTL_RAW.CAST_TO_VARCHAR2(v_buffer));
v_offset:=v_offset+v_buffer_size;
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
null;
END;
Re: displaying images from oracle 8i blob in asp [message #38066 is a reply to message #38063] Mon, 18 March 2002 02:04 Go to previous messageGo to next message
Ruaridh
Messages: 3
Registered: March 2002
Junior Member
Thanks for this, but I don't really understand.....
This procedure is the same as the one I have already, but when you say to call it with an IMG tag with 'your_server_name' in the path....do I specify the Oracle directory? The username? The Oracle instance ID?

My Oracle server is a different one from the one on which I'm running the ASP, and it doesn't have IIS installed. I'm not using the web server (Apache) part of Oracle either.

Is it still possible to use the procedure in this way??
Thanks,
Ruaridh
Re: displaying images from oracle 8i blob in asp [message #38068 is a reply to message #38063] Mon, 18 March 2002 02:15 Go to previous messageGo to next message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
one idea is to create a asp page let us say retrieveimage.asp which will take parameter as image_name.
1. set the mime type of the response object to image/jpeg.
2. pick the image_name from parameter list provided in url and read the blob image from databse and use response.write to write data to response object(see the code in previous post , it exactly uses same techique)
3. call the asp page as
img src=http://..server_name../retrive_image.asp?image_name=xyz

N.B. : i am not comfortable with asp, as i am never written code in asp , but i know the concepts. so, better u use the techinque an write the code yourself.sorry if i have messed u up

hope it helps!!!
Re: displaying images from oracle 8i blob in asp [message #38070 is a reply to message #38063] Mon, 18 March 2002 02:23 Go to previous messageGo to next message
Ruaridh
Messages: 3
Registered: March 2002
Junior Member
No problem, and thanks for taking the time to try and help.

I've basically been trying to do this, but in my page which is set to image/jpeg, when I call Response.BinaryWrite(execute my_procedure) I just get ASP 0185 - Missing Default Property, whatever that means, so I'm assuming this isn't the correct way to do it.
Re: displaying images from oracle 8i blob in asp [message #39071 is a reply to message #38063] Tue, 11 June 2002 20:30 Go to previous message
Ted
Messages: 9
Registered: June 2002
Junior Member
Good suggestion. I created an separate ASP page e.g. Customer.ASP that selects a blob jpeg from a Sybase SQL Anywhere 8 db via ADO using an index passed in thru a session variable. It then writes the blob out via Response.BinaryWrite. I create another ASP page that has normal HTML Text with other db data selected using the same index and when I embedded an image that refers to the other ASP page e.g. <img src=Customer.ASP> it worked! I got my normal HTML stuff and the image was replaced with the actual JPEG from the database. Believe would work same with Oracle 8i
Previous Topic: Name Matching Algorithim
Next Topic: Un committed Transactions
Goto Forum:
  


Current Time: Tue Apr 23 12:19:00 CDT 2024