Re: Loading Photos (jpg, gif...) in Oracle

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Wed, 19 May 1999 18:11:51 GMT
Message-ID: <3748fe90.26266108_at_newshost.us.oracle.com>


A copy of this was sent to Robert Lockard <rob_at_bcr8tv.com> (if that email address didn't require changing) On Wed, 19 May 1999 13:08:37 -0400, you wrote:

>I'm in the process of developing an application, and I'm stuck on one
>"small" detail. I have a large number if jpg's, and gif's that i would
>like to store in a table. I know this can be done, I'm just stuck on
>how are they loaded.
>
>I'm developing the app in 8.0.5, using java, and pro*c. When 8i is
>availiable on Linux, I will move development to that platform.
>
>Any Ideas, I know this can be done.
>
>Thank you.
>Robert Lockard
>CR8TV Inspirations, Inc.

easy way is dbms_lob.loadfromfile. For example:

drop table demo;
create table demo( id int primary key, theBlob blob) /

REM -- this is where the files are in the file system 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;
/

turn the above block into a stored procedure and then just call it with the file name for each file...

See http://www.oracle.com/ideveloper/ for my column 'Digging-in to Oracle8i'...  

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 Wed May 19 1999 - 20:11:51 CEST

Original text of this message