How do you insert image file, sound file using CLOB and BLOB.

Showing Answers 1 - 1 of 1 Answers

Nikhil_4_Oracle

  • Mar 1st, 2007
 

--This code will insert a image into database

  

create or replace PROCEDURE INSERT_BLOB(filE_namE IN VARCHAR2,dir_name varchar2)

IS

tmp number;

f_lob     bfile;

b_lob   blob;

BEGIN

dbms_output.put_line('INSERT BLOB Program Starts');

dbms_output.put_line('--------------------------');

dbms_output.put_line('File Name :'||filE_namE);

dbms_output.put_line('--------------------------');

UPDATE  photograph SET image=empty_blob()

WHERE file_name =filE_namE

returning image INTO b_lob;

f_lob := bfilename( 'BIS_IMAGE_WORKSPACE',filE_namE);

dbms_lob.fileopen(f_lob,dbms_lob.file_readonly);

--dbms_lob.loadfromfile(b_lob,f_lob,dbms_lob.getlength(f_lob));               

insert into photograph values (111,user,sysdate,b_lob);

dbms_lob.fileclose(f_lob);

dbms_output.put_line('BLOB Successfully Inserted');

dbms_output.put_line('--------------------------');

commit;

dbms_output.put_line('File length is: '||dbms_lob.getlength( f_lob));

dbms_output.put_line('Loaded length is: '||dbms_lob.getlength(b_lob));

dbms_output.put_line('BLOB Committed.Program Ends');

dbms_output.put_line('--------------------------');

END inserT_bloB;

/

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions