IF()の中でCursorを使用できますか?条件?私は以下のコードを試しました しかし、それは..誰も私はこれを解決するのを助ける?IF()内のカーソルThen
私のコードは次のとおりです。
BEGIN
IF EXISTS
((select '1'
from cttest c
where not exists(
select 1 from cof o where c.createddate > add_months(sysdate,-6) and c.ctid not in (
o.ctid , o.bctid, o.lc1, o.lc2, o.sslc1,o.sslc2)
) and c.lastupdated is null and c.lastupdatedcof is null)) THEN
begin
cursor ctdelete
IS
select ctid,ctname from cttest c
where not exists(
select 1 from cof o where c.createddate > add_months(sysdate,-6) and c.ctid not in (
o.ctid , o.bctid, o.lc1, o.lc2, o.sslc1,o.sslc2)
) and c.lastupdated is null and c.lastupdatedcof is null
end;
FOR reDel_audit IN ctdelete
LOOP
insert into ctaudit (ctid,ctname,v_IsDeleted,null,sysdate);
COMMIT;
END LOOP;
END;
エラーは次のとおりです。
エラー(22,8):PLS-00103:次のいずれかを期待したときにシンボル "ctdeleteを" が発生しました::=。 (%@;
あなたも、最初にカーソルが必要ですか?あなたのFOR LOOPはレコードの存在を評価します。 – Drumbeg
@Drumbegカーソルの結果に基づいて、私は各行を繰り返し、ctauditテーブルに挿入する必要があります。 –
さて、カーソルは私とほとんど同じように見えます。同じ基準に基づいてループを実行する前に、レコードの存在を確認する必要はないと考えてください。 – Drumbeg