有人可以解释如何将多个值传递给oracle case语句然后
SELECT *
FROM impl_debitor_information
WHERE soft_delete='F'
AND SHOP_ID ='4987bc1b-c0a8-6cb7-12f4-0243011f7099'
AND (debitor_type IS NULL
OR debitor_type IN (CASE
WHEN (SELECT techfund_debitor_enabled
FROM impl_shop
WHERE shop_id='4987bc1b-c0a8-6cb7-12f4-0243011f7099') = 'YES' THEN ('T','D')
ELSE 'D'
END))
如果值来自 从impl_shop中选择techfund_debitor_enabled,其中shop_id =' 4987bc1b-c0a8-6cb7-12f4-0243011f7099'是"是"然后我需要将2个值传递给in子句,如果不是单个值
提前致谢
答案 0 :(得分:1)
CASE只返回一个值。您必须重写您的查询。像这样:
SELECT *
FROM impl_debitor_information i, impl_shop where shop_id s
WHERE d.soft_delete='F'
AND d.shop_id ='4987bc1b-c0a8-6cb7-12f4-0243011f7099'
AND d.shop_id = s.shop_id
AND (d.debitor_type IS NULL
OR (d.debitor_type IN ('T','D') AND s.techfund_debitor_enabled = 'YES')
OR (d.debitor_type IN ('D') AND s.techfund_debitor_enabled <> 'YES'))
可能存在错误,我没有测试查询。