我遇到问题,让以下查询在UPDATE
命令下正常运行,但在我只是尝试对数据执行等效SELECT
时却没有。我在WHERE EXISTS
段上收到“语法错误”。我尝试修改WHERE EXISTS
以包含它之前的AND
,但后来又出现了另一种语法错误:
在期望条件的上下文中指定的非布尔类型的表达式
原始SQL UPDATE
声明:
UPDATE PS_RPLN_MSTR_TAO5
SET QTY_WIP_BASE = (SELECT A.QTY
FROM PS_WIP_QTY_INV_VW A
WHERE A.BUSINESS_UNIT = PS_RPLN_MSTR_TAO5.BUSINESS_UNIT_IN
AND A.INV_ITEM_ID = PS_RPLN_MSTR_TAO5.INV_ITEM_ID
AND PS_RPLN_MSTR_TAO5.INCL_WIP_QTY_FLG = 'Y'
AND PS_RPLN_MSTR_TAO5.BUSINESS_UNIT_IN = '82DDR'
AND PS_RPLN_MSTR_TAO5.PROCESS_INSTANCE = '8193747')
WHERE EXISTS (SELECT 'X'
FROM PS_WIP_QTY_INV_VW A
WHERE A.BUSINESS_UNIT = PS_RPLN_MSTR_TAO5.BUSINESS_UNIT_IN
AND A.INV_ITEM_ID = PS_RPLN_MSTR_TAO5.INV_ITEM_ID
AND PS_RPLN_MSTR_TAO5.INCL_WIP_QTY_FLG = 'Y'
AND PS_RPLN_MSTR_TAO5.BUSINESS_UNIT_IN = '82DDR'
AND PS_RPLN_MSTR_TAO5.PROCESS_INSTANCE = '8193747')
修改SELECT
查询(获取语法错误):
SELECT
A.QTY
FROM
PS_WIP_QTY_INV_VW A, PS_RPLN_MSTR_TAO5
WHERE
A.BUSINESS_UNIT = PS_RPLN_MSTR_TAO5.BUSINESS_UNIT_IN
AND A.INV_ITEM_ID = PS_RPLN_MSTR_TAO5.INV_ITEM_ID
AND PS_RPLN_MSTR_TAO5.INCL_WIP_QTY_FLG = 'Y'
AND PS_RPLN_MSTR_TAO5.BUSINESS_UNIT_IN = '82DDR'
AND PS_RPLN_MSTR_TAO5.PROCESS_INSTANCE = '8193747'
WHERE
EXISTS (SELECT 'X'
FROM PS_WIP_QTY_INV_VW A, PS_RPLN_MSTR_TAO5
WHERE A.BUSINESS_UNIT = PS_RPLN_MSTR_TAO5.BUSINESS_UNIT_IN
AND A.INV_ITEM_ID = PS_RPLN_MSTR_TAO5.INV_ITEM_ID
AND PS_RPLN_MSTR_TAO5.INCL_WIP_QTY_FLG = 'Y'
AND PS_RPLN_MSTR_TAO5.BUSINESS_UNIT_IN = '82DDR'
AND PS_RPLN_MSTR_TAO5.PROCESS_INSTANCE = '8193747')