我正在
错误(68,3):PLS-00435:没有BULK In-BIND的DML语句不能在FORALL中使用。
请帮我解决这个问题。
我的代码是: -
create or replace PACKAGE BODY FIBRE_TOOLS AS
g_package_name varchar2(30):='FIBRE_TOOLS';
g_proc_name varchar2(30);
.. .. ..
procedure prc_purge(p_nb_month IN number default 210) is
reqSelec VARCHAR2(4000);
reqDELDES VARCHAR2(4000);
reqDELINS VARCHAR2(4000);
TYPE Curseur IS REF CURSOR;
c_desinscription Curseur;
TYPE selREC IS RECORD (
EMAIL desinscription.EMAIL%type,
IDRA desinscription.IDRA%type,
D_DATE desinscription.desinscription_date%type
);
TYPE selTABLE IS TABLE OF selREC;
ListeFIB selTABLE;
BEGIN
reqSelec :='select EMAIL,IDRA,desinscription_date from desinscription where desinscription_date < trunc(add_months(sysdate,-'||p_nb_month||'))';
reqDELDES := 'DELETE FROM DESINSCRIPTION WHERE EMAIL=:1 AND IRDA=:2';
reqDELINS := 'DELETE FROM INSCRIPTION WHERE EMAIL=:1 AND IDRA=:2 AND INSCRIPTION_DATE < TRUNC(:3)';
prc_log('Begining of purging procedure');
open c_desinscription for reqSelec;
LOOP
fetch c_desinscription bulk collect into ListeFIB LIMIT 10000;
EXIT WHEN ListeFIB.count = 0;
FORALL i in ListeFIB.first.. ListeFIB.last
EXECUTE IMMEDIATE reqDELDES USING ListeFIB.EMAIL,ListeFIB.IRDA;
EXECUTE IMMEDIATE reqDELINS USING ListeFIB.EMAIL,ListeFIB.IDRA,ListeFIB.D_DATE;
COMMIT;
EXIT WHEN c_desinscription%NOTFOUND;
END LOOP;
close c_desinscription;
COMMIT;
prc_log('Ending of purging procedure');
end prc_purge;
end FIBRE_TOOLS;
我试图根据在标准I.e上选择的两列来从两个表中删除数据。 nb_months。
我认为问题在于表格类型和记录类型。我很困惑它可以做到哪种方式。据我所知,记录类型应与FORALL一起使用。请帮助我,因为它非常关键。
答案 0 :(得分:0)
您正在使用带有FORALL的DML语句但没有绑定使用的集合 - Oracle doesn't allow for that.
使用绑定的集合替换execute immediates,应该可以正常工作
EXECUTE IMMEDIATE reqDELDES USING ListeFIB(i).EMAIL,ListeFIB(i).IRDA;
EXECUTE IMMEDIATE reqDELINS USING ListeFIB(i).EMAIL,ListeFIB(i).IDRA,ListeFIB(i).D_DATE;
查看这些文章中的更多示例: