正确代码
"BEGIN
FOR ievt IN (
SELECT
evt_udfchar06,evt_code,evt_enteredby
FROM
r5events
WHERE rowid = :rowid ) LOOP
IF o7sess.cur_user = 'R5' AND ievt.evt_udfchar06 (SELECT evt_udfchar06 FROM r5events WHERE rowid <>:rowid) THEN
RAISE_APPLICATION_ERROR(-20004,''Incident number is associated with other WO.'');
END IF;
--o7sess.cur_user;
END LOOP;
END;"
PLS-00405: subquery not allowed in this context
if 条件是否允许子查询
if 条件是否允许子查询
没有。
无论使用:
SELECT ... INTO ...
在 IF
语句之前;或
检查光标中的其他行:
BEGIN
FOR ievt IN (
SELECT *
FROM (
SELECT evt_udfchar06,
evt_code,
evt_enteredby,
COUNT(*) OVER (PARTITION BY evt_udfchar06) AS num_rows
FROM r5events
)
WHERE rowid = :rowid
) LOOP
IF o7sess.cur_user = 'R5'
AND ievt.num_rows > 1
THEN
RAISE_APPLICATION_ERROR(-20004,'Incident number is associated with other WO.');
END IF;
--o7sess.cur_user;
END LOOP;
END;