-1

CASE 内に IF ステートメントを書き込もうとしていましたが、コンパイル エラーが発生しました。この私のコードは次のようになります

(CASE 
    IF (acc_type_id_ = 'ENDU') THEN
      WHEN PRODUCT_ID !=  product_id_ AND AVAIL_TO_SELL = 'YES' AND Enable_Add_To_Cart(PRODUCT_ID)='YES' AND PROD_ITEM_PKG.Get_Allow_Endu_Purch(PRODUCT_ID)='YES' THEN '&ACTION_ADD_TO_CART'                               
      WHEN PRODUCT_ID =  product_id_ AND AVAIL_TO_SELL = 'YES' AND Enable_Add_To_Cart(PRODUCT_ID)='YES' AND SELL_ONLY_LINKED != 'YES' AND PROD_ITEM_PKG.Get_Allow_Endu_Purch(PRODUCT_ID)='YES' THEN '&ACTION_ADD_TO_CART' 
    ELSE
       WHEN PRODUCT_ID !=  product_id_ AND AVAIL_TO_SELL = 'YES' AND Enable_Add_To_Cart(PRODUCT_ID)='YES' THEN '&ACTION_ADD_TO_CART'                               
       WHEN PRODUCT_ID =  product_id_ AND AVAIL_TO_SELL = 'YES' AND Enable_Add_To_Cart(PRODUCT_ID)='YES' AND SELL_ONLY_LINKED != 'YES' THEN '&ACTION_ADD_TO_CART' 
    END IF;   
ELSE '&ACTION_NO_ACTION'
END) ACTION2,

SQLPLUS のエラー

( begin case declare exit for goto if loop mod null pragma
raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
continue close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe purge
4

1 に答える 1

3

これはどうですか?同じ結果を達成するためacc_type_id_ = 'ENDU'の条件の一部として使用できます。WHEN

(CASE 
      WHEN acc_type_id_ = 'ENDU' AND PRODUCT_ID !=  product_id_ AND AVAIL_TO_SELL = 'YES' AND Enable_Add_To_Cart(PRODUCT_ID)='YES' AND PROD_ITEM_PKG.Get_Allow_Endu_Purch(PRODUCT_ID)='YES' THEN '&ACTION_ADD_TO_CART'                               
      WHEN acc_type_id_ = 'ENDU' AND PRODUCT_ID =  product_id_ AND AVAIL_TO_SELL = 'YES' AND Enable_Add_To_Cart(PRODUCT_ID)='YES' AND SELL_ONLY_LINKED != 'YES' AND PROD_ITEM_PKG.Get_Allow_Endu_Purch(PRODUCT_ID)='YES' THEN '&ACTION_ADD_TO_CART' 
      WHEN acc_type_id_ != 'ENDU' AND PRODUCT_ID !=  product_id_ AND AVAIL_TO_SELL = 'YES' AND Enable_Add_To_Cart(PRODUCT_ID)='YES' THEN '&ACTION_ADD_TO_CART'                               
      WHEN acc_type_id_ != 'ENDU' AND PRODUCT_ID =  product_id_ AND AVAIL_TO_SELL = 'YES' AND Enable_Add_To_Cart(PRODUCT_ID)='YES' AND SELL_ONLY_LINKED != 'YES' THEN '&ACTION_ADD_TO_CART' 
      ELSE '&ACTION_NO_ACTION'
END) ACTION2,
于 2013-01-06T11:31:20.830 に答える