Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle Web Application Server and Image Cartridge
A copy of this was sent to "Paul Bolton" <Paul.Bolton_at_matsushita-europe.com>
(if that email address didn't require changing)
On Thu, 14 May 1998 13:44:27 +0100, you wrote:
>I am trying to load data from a BLOB Image on and Oracle 8 database stored
>using the Image Cartridge into a Web page.
>
>I don't know wether I should use the DBMS_LOB.LOADFROMFILE procedure, and if
>so how?
>
>Any help gratefully received?
>
>Thanks
>Paul
>
>
You can just use PL/SQL.
Bear in mind that the character set for the PL/SQL cartridge must be the same as the character set of the database for this to work (we are dealing with RAWs here, can't let any NLS conversions happen).
also, this uses utl_raw which is shipped with the database since 7.1.6 (replication and gateways use it). If utl_raw is not installed in your database, simply goto your $ORACLE_HOME/rdbms/admin directory and look for the 2 files named "*raw*". There will be a spec and body. Use svrmgr to install them when connected as SYS or INTERNAL..
create or replace procedure get_blob( id in varchar2 ) is
l_lob blob; l_amt number default 4096; l_off number default 1; l_raw raw(4096);
begin
select b_lob into get_blob.l_lob from blobs where id = get_blob.id; exception when no_data_found then owa_util.status_line( 404, 'Not Found' );end;
begin
owa_util.mime_header( 'image/gif' ); loop dbms_lob.read( l_lob, l_amt, l_off, l_raw ); htp.prn( utl_raw.cast_to_varchar2(l_raw) ); l_off := l_off+l_amt; l_amt := 4096; end loop; exception when no_data_found then NULL;
So, assuming you have the blob in a table blobs ( id varchar2(25) primary key, b_lob blob ); A url like:
http://yourhost/plsql_agent/get_blob?id=myimage.gif
would query that table and return that blob to the browser. To embedd that gif in an html page, you would just code:
....
<img src=http://yourhost/plsql_agent/get_blob?id=myimage.gif>
...
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA
http://govt.us.oracle.com/ -- downloadable utilities
Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Thu May 14 1998 - 10:00:15 CDT
![]() |
![]() |