我在下面的查詢中使用了兩種情況來獲得&認證的結果ApprovalType。 在Oracle SQL中運行以下查詢時,會分別創建兩個新的臨時列,分別爲daction_1 & ApprovalType _ApprovalType列。現在,我想在IDOC代碼中使用這些關鍵字,但是由於臨時列已創建,所以我無法使用它們。如何解決這個問題?在Oracle SQL中結束爲關鍵字Case語句
SELECT WH.dActionDate,
WH.xWF_SendTo,
WH.dAction,
ATY.ApprovalType,
WH.xWorkflowComments,
CASE
WHEN NVL(ApprovalType,'') IS NULL
THEN xPurposeForRejection
ELSE ApprovalType
END AS ApprovalType,
CASE
WHEN NVL(dAction,'') ='SendTo'
AND NVL(ApprovalType,'') IS NOT NULL
OR NVL(dAction,'') ='Approve'
THEN 'Approve'
ELSE 'Reject'
END AS dAction
FROM WorkflowHistory WH,
Reason Re,
ApprovalType ATY
WHERE UPPER(dDocName) = UPPER('D_1239178')
AND xPurposeForSubmission = Re.ReasonID(+)
AND xDocApproval = ATY.ApprovalTypeID(+)
AND (dAction IN('Reject','Approve')
OR (dAction ='SendTo'
AND ApprovalType IS NOT NULL))
AND ROWNUM <= 5
ORDER BY dActionDate DESC,
dActionMillis
首先,'IDOC'代表什麼?其次,你已經爲MySQL和Oracle添加了標籤。你真的在使用哪一種?第三,你爲什麼要混淆你的'CASE'語句來使用與你已經選擇的列匹配的別名?你爲什麼不選擇一個獨特的別名,讓你區分這兩個? –
在Oracle中,空字符串被視爲Null,因此Nvl(dAction,'')與dAction –