联系:手机/微信(+86 17813235971) QQ(107644445)
作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]
--create directory create directory ULTLOBDIR as 'd:' --create table create table blobtest(col1 BLOB); create table clobtest(col1 cLOB); --insert BLOB declare a_blob BLOB; bfile_name BFILE := BFILENAME('ULTLOBDIR','teslob.doc'); begin insert into blobtest values (empty_blob()) returning col1 into a_blob; dbms_lob.fileopen(bfile_name); dbms_lob.loadfromfile(a_blob, bfile_name, dbms_lob.getlength(bfile_name)); dbms_lob.fileclose(bfile_name); commit; end; --update BLOB declare a_blob BLOB; bfile_name BFILE := BFILENAME('ULTLOBDIR','log.txt'); begin update blobtest set col1=empty_blob() where rownum=1 returning col1 into a_blob; dbms_lob.fileopen(bfile_name); dbms_lob.loadfromfile(a_blob, bfile_name, dbms_lob.getlength(bfile_name)); dbms_lob.fileclose(bfile_name); commit; end; --insert CLOB declare a_clob CLOB; bfile_name BFILE := BFILENAME('ULTLOBDIR','teslob.doc'); begin insert into clobtest values (empty_clob()) returning col1 into a_clob; dbms_lob.fileopen(bfile_name); dbms_lob.loadfromfile(a_clob, bfile_name, dbms_lob.getlength(bfile_name)); dbms_lob.fileclose(bfile_name); commit; end; --update CLOB declare a_clob CLOB; bfile_name BFILE := BFILENAME('ULTLOBDIR','log.txt'); begin update clobtest set col1=empty_clob() where rownum=1 returning col1 into a_clob; dbms_lob.fileopen(bfile_name); dbms_lob.loadfromfile(a_clob, bfile_name, dbms_lob.getlength(bfile_name)); dbms_lob.fileclose(bfile_name); commit; end; --查询是否成功 select dbms_lob.getlength(col1) from blobtest; select dbms_lob.getlength(col1) from clobtest;