IF() 안에 커서를 사용할 수 있습니까? 그렇다면 조건? 나는 아래의 코드를 시도했다 하지만 그것은 ..이 문제를 해결하는 데 도움 누군가가?커서 내부 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