我正在尝试编写一个 CURSOR 来在 Oracle 中执行任务。我不熟悉 Oracle 中的游标。显然我做错了什么。谁能告诉我它是什么?
DECLARE
CURSOR c1 IS
SELECT BADGE.EMPID
FROM EVENTS
INNER JOIN BADGE ON EVENTS.CARDNUM = BADGE.ID
INNER JOIN EMP ON BADGE.EMPID = EMP.ID
WHERE EMP.VISITOR = 0
AND EVENTS.EVENT_TIME_UTC - 0.125 > TO_DATE('20090101 00:00:00', 'RRRRMMDD hh24:mi:ss')
AND EVENTS.EVENT_TIME_UTC - 0.125 < TO_DATE('20120101 23:59:59', 'RRRRMMDD hh24:mi:ss');
r1 c1%ROWTYPE;
BEGIN
FOR r1 IN c1 LOOP
UPDATE EVENTS
SET EVENTS.EMPID = r1.EMPID
END LOOP;
END;
谢谢你的帮助!