在我的程序中,用户有4个选项," ALL"," FK"," FK2"," FK3"。由于数组,下面的代码不起作用。
WHERE
JOBOP.CC_CODE in
CASE :P4_MACHINES
WHEN 'ALL' THEN ('FK','FK2','FK3')
ELSE :P4_MACHINES
END
有人可以帮我正确地形成这个条款,或者告诉我,如果不可能吗?
只是以其他方式重申我的目标,
IF :P4_MACHINES = 'ALL' THEN
JOBOP.CC_CODE in ('FK','FK2','FK3')
ELSE
JOBOP.CC_CODE = P4_MACHINES
END
答案 0 :(得分:5)
根据您的问题更新,您可以尝试:
where ( (:P4_MACHINES = 'ALL' AND JOBOP.CC_CODE in ('FK','FK2','FK3'))
OR JOBOP.CC_CODE = :P4_MACHINES )
我可能缺少一些括号,因为我没有完整的查询。
答案 1 :(得分:4)
where (:P4_MACHINES = 'ALL' and JOBOP.CC_CODE in ('FK','FK2','FK3'))
or (JOBOP.CC_CODE = :P4_MACHINES)
答案 2 :(得分:0)
WHERE 1 = CASE WHEN :P4_MACHINES = 'ALL' THEN CASE WHEN JOBOP.CC_CODE IN ('FK','FK2','FK3') THEN 1 ELSE 0 END ELSE CASE WHEN JOBOP.CC_CODE = :P4_MACHINES THEN 1 ELSE 0 END END