然后将多个值赋给 oracle case 语句
multiple values to oracle case statement then
有人可以解释一下如何将多个值传递给 oracle case 语句 Then
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))
如果值来自
select techfund_debitor_enabled 来自 impl_shop 其中 shop_id='4987bc1b-c0a8-6cb7-12f4-0243011f7099' 是 "YES" 那么我需要将 2 个值传递给 in 子句, 如果不是单值
提前致谢
CASE 只会 return 一个值。您必须重写您的查询。像这样:
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'))
其中可能有错误,我没有测试查询。
有人可以解释一下如何将多个值传递给 oracle case 语句 Then
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))
如果值来自
select techfund_debitor_enabled 来自 impl_shop 其中 shop_id='4987bc1b-c0a8-6cb7-12f4-0243011f7099' 是 "YES" 那么我需要将 2 个值传递给 in 子句, 如果不是单值
提前致谢
CASE 只会 return 一个值。您必须重写您的查询。像这样:
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'))
其中可能有错误,我没有测试查询。