Oracle数据库的LOB字段学习_Oracle数据库_黑客防线网安服务器维护基地--Powered by WWW.RONGSEN.COM.CN

Oracle的LOB字段学习

作者:黑客防线网安Oracle维护基地 来源:黑客防线网安Oracle维护基地 浏览次数:0

黑客防线网安网讯:--插入bfile create or replace procedure insert_book(filename varchar2) as book_file bfile := NULL;bookExists boolean := false;beginbook_file := bfilename('BOOK_TEXT', f...

--插入bfile create or replace procedure insert_book(filename varchar2) as
book_file bfile := NULL;
bookExists boolean := false;
begin
book_file := bfilename('BOOK_TEXT', filename);
bookExists := dbms_lob.fileexists(book_file) = 1;

if bookExists then
insert into my_book_files values ((select count(*) from my_book_files) + 1 , book_file);
dbms_output.put_line('Insert sucess! file : ' || filename);
else
dbms_output.put_line('Not exists! file : ' || filename);
end if;
exception
when dbms_lob.noexist_directory then
dbms_output.put_line('Error: ' || sqlerrm);
when dbms_lob.invalid_directory then
dbms_output.put_line('Error : ' || sqlerrm);
when others then
dbms_output.put_line('Unkown Error : ' || sqlerrm);
end insert_book;
/

create or replace procedure insertPDF(fileName varchar2) is
fileLoc bfile;
nID number;
nPDFSize integer;
bFileExists boolean := false;
begin
fileLoc := bfilename('PDFDIR',filename);
bFileExists := dbms_lob.fileexists(fileLoc) = 1;
if bFileExists = false then
dbms_output.put_line(fileName || ' not exists');
return;
end if;

nPDFSize := dbms_lob.getlength(fileLoc);
dbms_output.put_line('the length of ' || fileName || ' is ' || nPDFSize);
select count(*) + 1 into nID from PDFTable;
insert into PDFTable(ID,Pdffile)
values (nID, fileLoc);
exception
when dbms_lob.noexist_directory then
dbms_output.put_line('Error: ' || sqlerrm);
when dbms_lob.invalid_directory then
dbms_output.put_line('Error : ' || sqlerrm);
when others then
dbms_output.put_line('Unkown Error : ' || sqlerrm);
end;
/

--插入 blob

CREATE OR REPLACE procedure insertImg(imgName varchar2) is
v_file_loc bfile;
v_image blob;
nID number;
nImgSize integer;
bFileExists boolean := false;
begin
v_file_loc := bfilename('IMAGEDIR', imgName);
bFileExists := dbms_lob.fileExists(v_file_loc) = 1;
if bFileExists = false then
dbms_output.put_line(imgName || ' not exists');
return;
end if;

    黑客防线网安服务器维护方案本篇连接:http://www.rongsen.com.cn/show-12775-1.html
网站维护教程更新时间:2012-03-23 00:45:39  【打印此页】  【关闭
我要申请本站N点 | 黑客防线官网 |  
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479

footer  footer  footer  footer