在儲存過程中操作ORACLE CLOB欄位
阿新 • • 發佈:2019-02-18
下面的 儲存過程演示了大資料不能一次插入資料庫的分批插入法,用到了ORACLE CLOB欄位
CREATE OR REPLACE PROCEDURE INSERT_RES_PEOPLE_ADD
(
r_people_cname varchar2,
r_people_intro varchar2
)
AS
r_intro_clob clob;--
buffer varchar2(32767);
amount number := 2000;
offset number := 1;
BEGIN
select clobf into r_intro_clob from ztable where RES_CLASS_ID = 9;
if r_intro_clob is null then
update ztable set clobf = 'buffer' where RES_CLASS_ID = 9;
return ;
end if;
amount := dbms_lob.getlength(r_intro_clob);
dbms_lob.read(r_intro_clob,amount,offset,buffer);
buffer := buffer || r_people_intro;
update ztable set clobf = buffer where RES_CLASS_ID = 9;
EXCEPTION
when others then
rollback;
--raise;
return;
END;