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: How to load pictures in Oracle 8?

Re: How to load pictures in Oracle 8?

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Mon, 26 Jul 1999 14:21:07 GMT
Message-ID: <37a06ea9.8545537@newshost.us.oracle.com>


A copy of this was sent to tedchyn_at_yahoo.com (if that email address didn't require changing) On Mon, 26 Jul 1999 13:47:34 GMT, you wrote:

>Thomas, Do you have corresponding code to retrieve the stored image and
>display it on a web browser(netscape or ie not appletviewer).
>
>Thanks Ted

assuming you have the PLSQL cartridge, it could look like:

create or replace package image_get
as

        procedure gif( p_id in demo.id%type );

end;
/

create or replace package body image_get as

procedure gif( p_id in demo.id%type )
is

        l_lob   blob;
        l_amt   number default 30;
        l_off   number default 1;
        l_raw   raw(4096);
begin
        select theBlob into l_lob
          from demo 
     where id = p_id;

        owa_util.mime_header( 'image/gif' );

        begin
                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;
        end;

end;

end;
/

Just make sure the NLS_LANG setting in the DAD is the same as the databases so no conversions take place!

>
>In article <379e75c7.98379432_at_newshost.us.oracle.com>,
> tkyte_at_us.oracle.com wrote:
>> A copy of this was sent to "jfguyard" <jfguyard_at_swissonline.ch>
>> (if that email address didn't require changing)
>> On Thu, 22 Jul 1999 12:19:47 GMT, you wrote:
>>
>> >Hi
>> >
>> >Could any oracle guru tell me how images (tiff, gif, jpeg) can be
>> >loaded into Oracle 8?
>> >Any further experience or recommandations are welcome.
>> >
>> >Thanks in advance and best regards.
>> >
>> >Jean François
>>
>> Here is one way to load:
>>
>> create table demo
>> ( id int primary key,
>> theBlob blob
>> )
>> /
>>
>> create or replace directory my_files as
>'/export/home/tkyte/public_html';
>>
>> declare
>> l_blob blob;
>> l_bfile bfile;
>> begin
>> insert into demo values ( 1, empty_blob() )
>> returning theBlob into l_blob;
>>
>> l_bfile := bfilename( 'MY_FILES', 'aria.gif' );
>> dbms_lob.fileopen( l_bfile );
>>
>> dbms_lob.loadfromfile( l_blob, l_bfile,
>> dbms_lob.getlength( l_bfile ) );
>>
>> dbms_lob.fileclose( l_bfile );
>> end;
>> /
>>
>> --
>> See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to
>Oracle8i'...
>> Current article is "Part I of V, Autonomous Transactions" updated
>June 21'st
>>
>> Thomas Kyte tkyte_at_us.oracle.com
>> Oracle Service Industries Reston, VA USA
>>
>> Opinions are mine and do not necessarily reflect those of Oracle
>Corporation
>>
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.

--
See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'... Current article is "Part I of V, Autonomous Transactions" updated June 21'st  

Thomas Kyte                   tkyte_at_us.oracle.com
Oracle Service Industries     Reston, VA   USA

Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Mon Jul 26 1999 - 09:21:07 CDT

Original text of this message

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