一个存储过程,关于blob

王朝other·作者佚名  2008-05-31
宽屏版  字体: |||超大  

好坏给点意见,谢了

代码:--------------------------------------------------------------------------------

create or replace procedure ps_cmpimage(

p_srtid in cmpimage.cimg_srtid%type,

p_id in cmpimage.cimg_id%type,

p_filename in varchar2,

p_title in cmpimage.cimg_title%type,

p_flag in number,

p_rowid in rowid)

is

image BLOB;

sourcefile BFILE;

cursor cur_cmpimage is

select a.cimg_count,a.cimg_idate from cmpimage a

where a.rowid=p_rowid;

rowimage cur_cmpimage%rowtype;

BEGIN

if p_flag=0 then

INSERT INTO cmpimage (cimg_srtid,cimg_id,cimg_image,cimg_title)

VALUES (p_srtid,p_id,EMPTY_BLOB,p_title)

RETURNING cimg_image INTO image;

sourcefile := BFILENAME('PHOTO_DIR',p_filename);

DBMS_LOB.OPEN(sourcefile, DBMS_LOB.LOB_READONLY);

DBMS_LOB.LOADFROMFILE(image,sourcefile,DBMS_LOB.GETLENGTH(sourcefile));

else

if p_filename is null then

update cmpimage a

set a.cimg_srtid=p_srtid,a.cimg_id=p_id,a.cimg_title=p_title

where a.rowid=p_rowid;

else

update cmpimage a

set a.cimg_srtid=p_srtid,a.cimg_id=p_id,a.cimg_title=p_title

where a.rowid=p_rowid;

select a.cimg_image into image from cmpimage a

where a.rowid=p_rowid

for update;

sourcefile := BFILENAME('PHOTO_DIR',p_filename);

DBMS_LOB.OPEN(sourcefile, DBMS_LOB.LOB_READONLY);

DBMS_LOB.LOADFROMFILE(image,sourcefile,DBMS_LOB.GETLENGTH(sourcefile));

end if;

end if;

commit;

end ps_cmpimage;--------------------------------------------------------------------------------

相关:

-- Create Directory

create or replace directory PHOTO_DIR

as 'C:\WINNT\TEMP\';

--grant

grant create any directory to 用户

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有