关注ORACLE ERP及开发工具
引用本人原创文章敬请注明出处
插入一个文件到DB中
上一篇 /
下一篇 2007-02-01 00:00:00
/ 个人分类:Oracle 开发
conn system/system ITPUB个人空间3et3Nc8^3I
I
grant create any directory to test;
k1r$K8|0r{-^/?1r7590422conn test/test
Y$~_j-_b _6L7590422create table demo (id int primary key,theclob clob);
6\0WZm He2\d0w7590422create or replace directory my_file as ‘d:’; ITPUB个人空间9dm%q+HR3g'@ v
B
create or replace procedure load_a_file(p_id in number,
[Hx
B?;O9n7590422 p_filename in varchar2) as
G&_j9\9o+H
Q/u&l7590422 l_clob clob; ITPUB个人空间 Q]#Kg#v
l_bfile bfile; ITPUB个人空间4wJ A8QKw
~
begin ITPUB个人空间uL%aD6KW
yEA
insert into demo ITPUB个人空间#BL*pk#E!EE
values
*S
HV3n9]5P x Z7590422 (p_id, empty_clob())
"k{(n'iw3uV5U
Cl7590422 returning theClob into l_clob;
pz0m A
U| P\7590422 l_bfile := bfilename('MY_FILES', p_filename);
AE}P!gbf)ro7590422 dbms_lob.fileopen(l_bfile); ITPUB个人空间|!\_[Ik
dbms_lob.loadfromfile(l_clob, l_bfile, dbms_lob.getlength(l_bfile)); ITPUB个人空间1L6J3@4O8]
dbms_lob.fileclose(l_bfile);
u0t8G/ATf7590422end;
:Q6F
|0y?ePm3k7590422exec load_a_file( 1, 'index.html' ); 1y;|Rez~7590422
导入论坛
引用链接
收藏
分享给好友
推荐到圈子
管理
举报
TAG: