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: inserting images into BLOB column

Re: inserting images into BLOB column

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Tue, 25 Jan 2000 08:37:05 -0500
Message-ID: <il9r8ssrdukum6r6psuofkip6ji547h15t@4ax.com>


A copy of this was sent to Laurent Feral-Pierssens <kafka_at_stones.com> (if that email address didn't require changing) On Tue, 25 Jan 2000 06:18:45 GMT, you wrote:

>
>I have one question. I have created a table with a BLOB column to store
>images. The only problem is that I have no idea how to insert data into
>this column. I've heard that I can 1. store the data in the field or 2.
>store a link from the field to the server. In both cases It appears that
>I cannot find any info on how to perform the insertion.
>
>Thanks for your help,
> Kafka
>

See the details on the dbms_lob package. You can read/write lobs 32k at a time (sort of like fread/fwrite in C). You can load lobs from files in one call.

Here is a short example but see the plsql manual in 8.0 or the LOB manual in 8i.

drop table demo;

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://osi.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 Tue Jan 25 2000 - 07:37:05 CST

Original text of this message

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