0
我的示例代碼。在where子句中使用select語句內的情況。流汗錯誤ORA-00905
在where條件裏的case語句,而我等同於變量,我得到以下錯誤:
ORA-00905缺失關鍵字
我不瞭解我出錯的地方。
我甚至嘗試完全等同case語句的變量,它沒有得到所需的輸出。
任何人都可以幫助我嗎?
SELECT JOB_NAME,
HOURS,
COMMITTEE,
REPORT,
DIRECTOR,
(CASE
WHEN L.ACTION IN ('110', '10') AND
L.APPROVED = 'Y' AND
(:LV_ACTN = '1' OR :LV_ACTN = '4') THEN
L.APPRV_JUSTIFY
WHEN L.ACTION IN ('20', '130') AND
L.FLAG = 'R' AND (:LV_ACTN = '2' OR :LV_ACTN = '4') THEN
L.CANCL_JUSTIFY
WHEN L.ACTION IN ('30', '120') AND
L.APPROVED = 'Y' AND
(:LV_ACTN = '3' OR :LV_ACTN = '4') THEN
L.POSTPONE_JUSTIFY
ELSE
'NO ACTION'
END) AS EXPLANATION,
L.ID,
MANAGER,
l.year
FROM PLAN L
WHERE (CASE WHEN
L.ACTION IN ('110', '10') AND
L.APPROVED = 'Y' AND
(:LV_ACTN = '1' OR :LV_ACTN = '4') THEN 'X'
WHEN L.ACTION IN ('20', '130') AND
L.FLAG = 'R' AND (:LV_ACTN = '2' OR :LV_ACTN = '4') THEN 'X'
WHEN L.ACTION IN ('30', '120') AND
L.APPROVED = 'Y' AND
(:LV_ACTN = '3' OR :LV_ACTN = '4') THEN X' END) IS NOT NULL
AND ((case when L.ACTION IN ('30', '120') THEN
(SELECT DISTINCT AV.YEAR
FROM PLAN_V AV
WHERE L.ID = AV.ID
AND AV.B_ID =
(SELECT MAX(B_ID)
FROM MS_AUD_AUDIT_PLAN_V
WHERE B_ID <
(SELECT MAX(B_ID)
FROM PLAN_V
WHERE ACTION = '120')))**=:LV_PLANYR** ELSE
L.YEAR END)**= :LV_PLANYR**)
你缺少在上面的SQL的33線的X單引號。這是一個錯字還是問題? – CathalMF