我已经写了一个程序,并且我已经使用了多个Sql语句,但是在一个语句中我遇到了问题,所以我的问题出现在下面的查询中。在我的查询中有一个名为ULE.ULE_ORIGINAL_PFS的引用句柄,并且此引用句柄的值可以是数字或MASTER_DATA_NO_AVAILABLE或INVALID_ENTRY,因此我的要求是每当引用句柄的值为MASTER_DATA_NO_AVAILABLE或INVALID_ENTRY时,我必须将其视为'' 0'所以请帮助我解决这个问题因为我很难使用DECODE或NVL。
SELECT SUM(ORF.ORDER_RELEASE_REFNUM_VALUE)
INTO V_OR_ORIGINAL_PFS
FROM ORDER_RELEASE_REFNUM ORF ,
VIEW_SHIPMENT_ORDER_RELEASE VSOR,
SHIPMENT SH ,
ORDER_RELEASE ORR
WHERE ORF.ORDER_RELEASE_GID = VSOR.ORDER_RELEASE_GID
AND VSOR.SHIPMENT_GID = SH.SHIPMENT_GID
AND ORR.ORDER_RELEASE_GID = ORF.ORDER_RELEASE_GID
AND ORF.ORDER_RELEASE_REFNUM_QUAL_GID = 'ULE.ULE_ORIGINAL_PFS'
AND SH.SHIPMENT_GID = P_SHIPMENT_GID
AND ORR.ORDER_RELEASE_GID IN
(SELECT ORR.ORDER_RELEASE_GID
FROM VIEW_SHIPMENT_ORDER_RELEASE VSOR,
SHIPMENT SH ,
ORDER_RELEASE ORR
WHERE VSOR.ORDER_RELEASE_GID = ORR.ORDER_RELEASE_GID
AND VSOR.SHIPMENT_GID = SH.SHIPMENT_GID
AND SH.SHIPMENT_GID = P_SHIPMENT_GID
AND ORR.ORDER_RELEASE_GID NOT IN
(SELECT ORF.ORDER_RELEASE_GID
FROM VIEW_SHIPMENT_ORDER_RELEASE VSOR,
SHIPMENT SH ,
ORDER_RELEASE_REFNUM ORF
WHERE VSOR.ORDER_RELEASE_GID = ORF.ORDER_RELEASE_GID
AND VSOR.SHIPMENT_GID = SH.SHIPMENT_GID
AND ORF.ORDER_RELEASE_REFNUM_QUAL_GID = 'ULE.ULE_UNPLANNED_ICT'
AND SH.SHIPMENT_GID = P_SHIPMENT_GID
)
);
答案 0 :(得分:0)
“我的查询中有一个名为ULE.ULE_ORIGINAL_PFS的引用句柄”
您的查询没有意义,但也许这就是您编辑它以便在此处发布的方式。
“我很困惑使用DECODE或NVL”
也许不使用,但选择CASE()而不是行业标准:
AND ORF.ORDER_RELEASE_REFNUM_QUAL_GID =
case ULE.ULE_ORIGINAL_PFS
when 'MASTER_DATA_NO_AVAILABLE' then 0
when 'INVALID_ENTRY' then 0
else ULE.ULE_ORIGINAL_PFS
end