2012-04-24 7 views
-1

IF文に基づいて異なるSELECT文を実行する必要がある問合せを作成しています。前にOracleでIFを実行していないが、何が間違っているのか分からないが、エラーが発生している。反復回数はゼロで、コードの最初の行を指している。私はコードを含めましたが、それはたくさんありますが、実際にはIFに注意を払う必要があります。PL SQLのゼロ反復回数Oracle

IF :p_sales_type = 'all_cancel' THEN 



    SELECT 
    TO_DATE(SUBSTR(Transaction_Date,1,10), 'MM/DD/YYYY'),Item_Number, 
    REGEXP_REPLACE(SUBSTR(Item_Or_Adj_Description,1,50),'([^[:print:]])',' ') AS Item_Or_Adj_Desctription, 
    Customer_Type, Document_ID, Dealer_ID, Sales_Type, Item_Quantity, Total_Fee, State_Fee, Transaction_Fee, AO_Fee, WDFW_Fee 
    FROM 
    ( 
    -- Sales Transactions 
    SELECT /*+ index(IT ITEM_X4) */ 
     TO_CHAR(IT.it_status_set_date - 2/24, 'MM/DD/YYYY HH24:MI:SS') AS Transaction_Date, -- Pacific Time 
     TO_NUMBER(IT.ic_rcn) AS Item_Number, IT.it_descr AS Item_Or_Adj_Description, 
     DT.di_name AS Customer_Type, IT.it_docid AS Document_ID, IT.ag_id AS Dealer_ID, 
     CASE WHEN UPPER(IST.is_name) = 'ACTIVE' THEN 'SALE' ELSE IST.is_name END AS Sales_Type, 
     NVL(IT.it_quantity * CASE WHEN IT.is_id = 'AC' THEN 1 WHEN IT.is_id = 'DU' THEN 1 ELSE -1 END, 0) AS Item_Quantity, -- Dups = 1 
     NVL(IT.it_state_fee * CASE WHEN IT.is_id IN ('DC','SC') THEN -1.00 ELSE 1.00 END, 0.00) + 
    NVL(IT.it_other_fee * CASE WHEN IT.is_id IN ('DC','SC') THEN -1.00 ELSE 1.00 END, 0.00) AS Total_Fee, 
     NVL(IT.it_state_fee * CASE WHEN IT.is_id IN ('DC','SC') THEN -1.00 ELSE 1.00 END, 0.00) AS State_Fee, 
     NVL(IT.it_other_fee * CASE WHEN IT.is_id IN ('DC','SC') THEN -1.00 ELSE 1.00 END, 0.00) AS Transaction_Fee, 
     CASE WHEN IT.it_other_fee IS NULL OR IT.it_other_fee = 0.00 THEN 0.00 
     ELSE ROUND(IT.it_state_fee * CASE WHEN IT.is_id IN ('DC','SC') THEN -1.00 ELSE 1.00 END * (:p_ao_trx_fee/100), 2) 
     END AS AO_Fee, 
     CASE WHEN IT.it_other_fee IS NULL OR IT.it_other_fee = 0.00 THEN 0.00 
     ELSE (IT.it_other_fee * CASE WHEN IT.is_id IN ('DC','SC') THEN -1.00 ELSE 1.00 END) - 
      ROUND((IT.it_state_fee * CASE WHEN IT.is_id IN ('DC','SC') THEN -1.00 ELSE 1.00 END * (:p_ao_trx_fee/100)), 2) 
     END AS WDFW_Fee 
    FROM ITEM IT 
    JOIN DISCOUNT_TYPE DT ON DT.di_id = IT.di_id 
    JOIN ITEM_STATUS_TYPE IST ON IST.is_id = IT.is_id 
    WHERE IT.it_status_ind = 'A' -- Include active ITEM rows only. 
    AND (IT.is_id IN ('AC','DC','SC') OR (IT.is_id = 'DU' AND NVL(IT.it_state_fee, 0) != 0)) -- Exclude voids, exchanges, and false duplicates. 
    AND IT.ic_rcn != '999' -- Exclude Dealer Fees. 
    AND IT.it_status_set_date BETWEEN :P_beg_dt -- Pacific Time 
       AND :P_end_dt 
    AND (:p_discount_type IS NULL OR DT.di_id = :p_discount_type) 
    -- AND IST.is_name = :SalesType 
    UNION ALL 

    -- Item Adjustments 
    SELECT 
     TO_CHAR(AJ.aj_adjustment_date - 2/24, 'MM/DD/YYYY HH24:MI:SS') AS Transaction_Date, -- Pacific Time 
     TO_NUMBER(IT.ic_rcn) AS Item_Number, AJ.aj_comment AS Item_Or_Adj_Description, 
     DT.di_name AS Customer_Type, IT.it_docid AS Document_ID, AJ.ag_id AS Dealer_ID, 
     AJ.ajt_adjustment_type_name AS Sales_Type, 
     0 AS Item_Quantity, 
     NVL(AJ.aj_state_adj_amt, 0.00) + NVL(AJ.aj_other_adj_amt, 0.00) AS Total_Fee, 
     NVL(AJ.aj_state_adj_amt, 0.00) AS State_Fee, 
     NVL(AJ.aj_other_adj_amt, 0.00) AS Transaction_Fee, 
     CASE WHEN AJ.aj_other_adj_amt IS NULL OR AJ.aj_other_adj_amt = 0.00 THEN 0.00 
    ELSE ROUND(NVL(AJ.aj_state_adj_amt, 0.00) * (:p_ao_trx_fee/100), 2) END AS AO_Fee, 
     CASE WHEN AJ.aj_other_adj_amt IS NULL OR AJ.aj_other_adj_amt = 0.00 THEN 0.00 
    ELSE AJ.aj_other_adj_amt - ROUND(NVL(AJ.aj_state_adj_amt, 0.00) * (:p_ao_trx_fee/100), 2) END AS WDFW_Fee 
    FROM ADJUSTMENT AJ 
    JOIN ITEM IT ON IT.it_id = AJ.it_id 
    JOIN DISCOUNT_TYPE DT ON DT.di_id = IT.di_id 
    WHERE AJ.aj_status_ind = 'A' -- Include active adjustments only. 
    AND AJ.it_id IS NOT NULL -- Include Item Adjustments only; rows with a foreign key to the ITEM table are Item Adjustments. 
    AND AJ.ajt_id != '0' -- Unreturned Doc Charge is not an Item Adjustment, it's a Lump Sum Adjustment to the Dealers account. 
    AND IT.ic_rcn != '999' -- Exclude Dealer Fees. 
    AND AJ.aj_adjustment_date BETWEEN :P_beg_dt -- Pacific Time 
       AND :P_end_dt 
    AND (:p_discount_type IS NULL OR DT.di_id = :p_discount_type) 
    --AND AJ.Ajt_Adjustment_Type_Name = :SalesType 
) ReportDetails 

    WHERE-- Sales_Type = :SalesType 
       (:p_ic_rcn is null OR :p_ic_rcn = Item_Number) 
       AND (:p_dealer_id IS NULL OR Dealer_ID = :p_dealer_id) 
       AND Sales_Type in ('DEALER CANCEL', 'STATE CANCEL') 



    ORDER BY TO_DATE(SUBSTR(Transaction_Date,1,10), 'MM/DD/YYYY'), Item_Number, -- Transaction Date, RCN (numerical order), order RCN was purchased. 
     TO_CHAR(TO_DATE(Transaction_Date, 'MM/DD/YYYY HH24:MI:SS'), 'SSSSS'); 


    ELSE IF :p_sales_type = 'item_adjustment' THEN 


    -- Item Adjustments 
    SELECT 
     TO_CHAR(AJ.aj_adjustment_date - 2/24, 'MM/DD/YYYY HH24:MI:SS') AS Transaction_Date, -- Pacific Time 
     TO_NUMBER(IT.ic_rcn) AS Item_Number, AJ.aj_comment AS Item_Or_Adj_Description, 
     DT.di_name AS Customer_Type, IT.it_docid AS Document_ID, AJ.ag_id AS Dealer_ID, 
     AJ.ajt_adjustment_type_name AS Sales_Type, 
     0 AS Item_Quantity, 
     NVL(AJ.aj_state_adj_amt, 0.00) + NVL(AJ.aj_other_adj_amt, 0.00) AS Total_Fee, 
     NVL(AJ.aj_state_adj_amt, 0.00) AS State_Fee, 
     NVL(AJ.aj_other_adj_amt, 0.00) AS Transaction_Fee, 
     CASE WHEN AJ.aj_other_adj_amt IS NULL OR AJ.aj_other_adj_amt = 0.00 THEN 0.00 
    ELSE ROUND(NVL(AJ.aj_state_adj_amt, 0.00) * (:p_ao_trx_fee/100), 2) END AS AO_Fee, 
     CASE WHEN AJ.aj_other_adj_amt IS NULL OR AJ.aj_other_adj_amt = 0.00 THEN 0.00 
    ELSE AJ.aj_other_adj_amt - ROUND(NVL(AJ.aj_state_adj_amt, 0.00) * (:p_ao_trx_fee/100), 2) END AS WDFW_Fee 
    FROM ADJUSTMENT AJ 
    JOIN ITEM IT ON IT.it_id = AJ.it_id 
    JOIN DISCOUNT_TYPE DT ON DT.di_id = IT.di_id 
    WHERE AJ.aj_status_ind = 'A' -- Include active adjustments only. 
    AND AJ.it_id IS NOT NULL -- Include Item Adjustments only; rows with a foreign key to the ITEM table are Item Adjustments. 
    AND AJ.ajt_id != '0' -- Unreturned Doc Charge is not an Item Adjustment, it's a Lump Sum Adjustment to the Dealers account. 
    AND IT.ic_rcn != '999' -- Exclude Dealer Fees. 
    AND AJ.aj_adjustment_date BETWEEN :P_beg_dt -- Pacific Time 
       AND :P_end_dt 
    AND (:p_discount_type IS NULL OR DT.di_id = :p_discount_type) 
    WHERE-- Sales_Type = :SalesType 
       (:p_ic_rcn is null OR :p_ic_rcn = Item_Number) 
       AND (:p_dealer_id IS NULL OR Dealer_ID = :p_dealer_id) 
       AND Sales_Type = 'ADJUSTMENT' 

    ORDER BY TO_DATE(SUBSTR(Transaction_Date,1,10), 'MM/DD/YYYY'), Item_Number, -- Transaction Date, RCN (numerical order), order RCN was purchased. 
     TO_CHAR(TO_DATE(Transaction_Date, 'MM/DD/YYYY HH24:MI:SS'), 'SSSSS'); 

    ELSE IF :p_sales_type IS NULL 


    SELECT 
    TO_DATE(SUBSTR(Transaction_Date,1,10), 'MM/DD/YYYY'),Item_Number, 
    REGEXP_REPLACE(SUBSTR(Item_Or_Adj_Description,1,50),'([^[:print:]])',' ') AS Item_Or_Adj_Desctription, 
    Customer_Type, Document_ID, Dealer_ID, Sales_Type, Item_Quantity, Total_Fee, State_Fee, Transaction_Fee, AO_Fee, WDFW_Fee 
    FROM 
    ( 
    -- Sales Transactions 
    SELECT /*+ index(IT ITEM_X4) */ 
     TO_CHAR(IT.it_status_set_date - 2/24, 'MM/DD/YYYY HH24:MI:SS') AS Transaction_Date, -- Pacific Time 
     TO_NUMBER(IT.ic_rcn) AS Item_Number, IT.it_descr AS Item_Or_Adj_Description, 
     DT.di_name AS Customer_Type, IT.it_docid AS Document_ID, IT.ag_id AS Dealer_ID, 
     CASE WHEN UPPER(IST.is_name) = 'ACTIVE' THEN 'SALE' ELSE IST.is_name END AS Sales_Type, 
     NVL(IT.it_quantity * CASE WHEN IT.is_id = 'AC' THEN 1 WHEN IT.is_id = 'DU' THEN 1 ELSE -1 END, 0) AS Item_Quantity, -- Dups = 1 
     NVL(IT.it_state_fee * CASE WHEN IT.is_id IN ('DC','SC') THEN -1.00 ELSE 1.00 END, 0.00) + 
    NVL(IT.it_other_fee * CASE WHEN IT.is_id IN ('DC','SC') THEN -1.00 ELSE 1.00 END, 0.00) AS Total_Fee, 
     NVL(IT.it_state_fee * CASE WHEN IT.is_id IN ('DC','SC') THEN -1.00 ELSE 1.00 END, 0.00) AS State_Fee, 
     NVL(IT.it_other_fee * CASE WHEN IT.is_id IN ('DC','SC') THEN -1.00 ELSE 1.00 END, 0.00) AS Transaction_Fee, 
     CASE WHEN IT.it_other_fee IS NULL OR IT.it_other_fee = 0.00 THEN 0.00 
     ELSE ROUND(IT.it_state_fee * CASE WHEN IT.is_id IN ('DC','SC') THEN -1.00 ELSE 1.00 END * (:p_ao_trx_fee/100), 2) 
     END AS AO_Fee, 
     CASE WHEN IT.it_other_fee IS NULL OR IT.it_other_fee = 0.00 THEN 0.00 
     ELSE (IT.it_other_fee * CASE WHEN IT.is_id IN ('DC','SC') THEN -1.00 ELSE 1.00 END) - 
      ROUND((IT.it_state_fee * CASE WHEN IT.is_id IN ('DC','SC') THEN -1.00 ELSE 1.00 END * (:p_ao_trx_fee/100)), 2) 
     END AS WDFW_Fee 
    FROM ITEM IT 
    JOIN DISCOUNT_TYPE DT ON DT.di_id = IT.di_id 
    JOIN ITEM_STATUS_TYPE IST ON IST.is_id = IT.is_id 
    WHERE IT.it_status_ind = 'A' -- Include active ITEM rows only. 
    AND (IT.is_id IN ('AC','DC','SC') OR (IT.is_id = 'DU' AND NVL(IT.it_state_fee, 0) != 0)) -- Exclude voids, exchanges, and false duplicates. 
    AND IT.ic_rcn != '999' -- Exclude Dealer Fees. 
    AND IT.it_status_set_date BETWEEN :P_beg_dt -- Pacific Time 
       AND :P_end_dt 
    AND (:p_discount_type IS NULL OR DT.di_id = :p_discount_type) 
    -- AND IST.is_name = :SalesType 
    UNION ALL 

    -- Item Adjustments 
    SELECT 
     TO_CHAR(AJ.aj_adjustment_date - 2/24, 'MM/DD/YYYY HH24:MI:SS') AS Transaction_Date, -- Pacific Time 
     TO_NUMBER(IT.ic_rcn) AS Item_Number, AJ.aj_comment AS Item_Or_Adj_Description, 
     DT.di_name AS Customer_Type, IT.it_docid AS Document_ID, AJ.ag_id AS Dealer_ID, 
     AJ.ajt_adjustment_type_name AS Sales_Type, 
     0 AS Item_Quantity, 
     NVL(AJ.aj_state_adj_amt, 0.00) + NVL(AJ.aj_other_adj_amt, 0.00) AS Total_Fee, 
     NVL(AJ.aj_state_adj_amt, 0.00) AS State_Fee, 
     NVL(AJ.aj_other_adj_amt, 0.00) AS Transaction_Fee, 
     CASE WHEN AJ.aj_other_adj_amt IS NULL OR AJ.aj_other_adj_amt = 0.00 THEN 0.00 
    ELSE ROUND(NVL(AJ.aj_state_adj_amt, 0.00) * (:p_ao_trx_fee/100), 2) END AS AO_Fee, 
     CASE WHEN AJ.aj_other_adj_amt IS NULL OR AJ.aj_other_adj_amt = 0.00 THEN 0.00 
    ELSE AJ.aj_other_adj_amt - ROUND(NVL(AJ.aj_state_adj_amt, 0.00) * (:p_ao_trx_fee/100), 2) END AS WDFW_Fee 
    FROM ADJUSTMENT AJ 
    JOIN ITEM IT ON IT.it_id = AJ.it_id 
    JOIN DISCOUNT_TYPE DT ON DT.di_id = IT.di_id 
    WHERE AJ.aj_status_ind = 'A' -- Include active adjustments only. 
    AND AJ.it_id IS NOT NULL -- Include Item Adjustments only; rows with a foreign key to the ITEM table are Item Adjustments. 
    AND AJ.ajt_id != '0' -- Unreturned Doc Charge is not an Item Adjustment, it's a Lump Sum Adjustment to the Dealers account. 
    AND IT.ic_rcn != '999' -- Exclude Dealer Fees. 
    AND AJ.aj_adjustment_date BETWEEN :P_beg_dt -- Pacific Time 
       AND :P_end_dt 
    AND (:p_discount_type IS NULL OR DT.di_id = :p_discount_type) 
    --AND AJ.Ajt_Adjustment_Type_Name = :SalesType 
) ReportDetails 

    WHERE   (:p_ic_rcn is null OR :p_ic_rcn = Item_Number) 
       AND (:p_dealer_id IS NULL OR Dealer_ID = :p_dealer_id) 



    ORDER BY TO_DATE(SUBSTR(Transaction_Date,1,10), 'MM/DD/YYYY'), Item_Number, -- Transaction Date, RCN (numerical order), order RCN was purchased. 
     TO_CHAR(TO_DATE(Transaction_Date, 'MM/DD/YYYY HH24:MI:SS'), 'SSSSS'); 


ELSE 

    SELECT 
    TO_DATE(SUBSTR(Transaction_Date,1,10), 'MM/DD/YYYY'),Item_Number, 
    REGEXP_REPLACE(SUBSTR(Item_Or_Adj_Description,1,50),'([^[:print:]])',' ') AS Item_Or_Adj_Desctription, 
    Customer_Type, Document_ID, Dealer_ID, Sales_Type, Item_Quantity, Total_Fee, State_Fee, Transaction_Fee, AO_Fee, WDFW_Fee 
    FROM 
    ( 
    -- Sales Transactions 
    SELECT /*+ index(IT ITEM_X4) */ 
     TO_CHAR(IT.it_status_set_date - 2/24, 'MM/DD/YYYY HH24:MI:SS') AS Transaction_Date, -- Pacific Time 
     TO_NUMBER(IT.ic_rcn) AS Item_Number, IT.it_descr AS Item_Or_Adj_Description, 
     DT.di_name AS Customer_Type, IT.it_docid AS Document_ID, IT.ag_id AS Dealer_ID, 
     CASE WHEN UPPER(IST.is_name) = 'ACTIVE' THEN 'SALE' ELSE IST.is_name END AS Sales_Type, 
     NVL(IT.it_quantity * CASE WHEN IT.is_id = 'AC' THEN 1 WHEN IT.is_id = 'DU' THEN 1 ELSE -1 END, 0) AS Item_Quantity, -- Dups = 1 
     NVL(IT.it_state_fee * CASE WHEN IT.is_id IN ('DC','SC') THEN -1.00 ELSE 1.00 END, 0.00) + 
    NVL(IT.it_other_fee * CASE WHEN IT.is_id IN ('DC','SC') THEN -1.00 ELSE 1.00 END, 0.00) AS Total_Fee, 
     NVL(IT.it_state_fee * CASE WHEN IT.is_id IN ('DC','SC') THEN -1.00 ELSE 1.00 END, 0.00) AS State_Fee, 
     NVL(IT.it_other_fee * CASE WHEN IT.is_id IN ('DC','SC') THEN -1.00 ELSE 1.00 END, 0.00) AS Transaction_Fee, 
     CASE WHEN IT.it_other_fee IS NULL OR IT.it_other_fee = 0.00 THEN 0.00 
     ELSE ROUND(IT.it_state_fee * CASE WHEN IT.is_id IN ('DC','SC') THEN -1.00 ELSE 1.00 END * (:p_ao_trx_fee/100), 2) 
     END AS AO_Fee, 
     CASE WHEN IT.it_other_fee IS NULL OR IT.it_other_fee = 0.00 THEN 0.00 
     ELSE (IT.it_other_fee * CASE WHEN IT.is_id IN ('DC','SC') THEN -1.00 ELSE 1.00 END) - 
      ROUND((IT.it_state_fee * CASE WHEN IT.is_id IN ('DC','SC') THEN -1.00 ELSE 1.00 END * (:p_ao_trx_fee/100)), 2) 
     END AS WDFW_Fee 
    FROM ITEM IT 
    JOIN DISCOUNT_TYPE DT ON DT.di_id = IT.di_id 
    JOIN ITEM_STATUS_TYPE IST ON IST.is_id = IT.is_id 
    WHERE IT.it_status_ind = 'A' -- Include active ITEM rows only. 
    AND (IT.is_id IN ('AC','DC','SC') OR (IT.is_id = 'DU' AND NVL(IT.it_state_fee, 0) != 0)) -- Exclude voids, exchanges, and false duplicates. 
    AND IT.ic_rcn != '999' -- Exclude Dealer Fees. 
    AND IT.it_status_set_date BETWEEN :P_beg_dt -- Pacific Time 
       AND :P_end_dt 
    AND (:p_discount_type IS NULL OR DT.di_id = :p_discount_type) 
    -- AND IST.is_name = :SalesType 
    UNION ALL 

    -- Item Adjustments 
    SELECT 
     TO_CHAR(AJ.aj_adjustment_date - 2/24, 'MM/DD/YYYY HH24:MI:SS') AS Transaction_Date, -- Pacific Time 
     TO_NUMBER(IT.ic_rcn) AS Item_Number, AJ.aj_comment AS Item_Or_Adj_Description, 
     DT.di_name AS Customer_Type, IT.it_docid AS Document_ID, AJ.ag_id AS Dealer_ID, 
     AJ.ajt_adjustment_type_name AS Sales_Type, 
     0 AS Item_Quantity, 
     NVL(AJ.aj_state_adj_amt, 0.00) + NVL(AJ.aj_other_adj_amt, 0.00) AS Total_Fee, 
     NVL(AJ.aj_state_adj_amt, 0.00) AS State_Fee, 
     NVL(AJ.aj_other_adj_amt, 0.00) AS Transaction_Fee, 
     CASE WHEN AJ.aj_other_adj_amt IS NULL OR AJ.aj_other_adj_amt = 0.00 THEN 0.00 
    ELSE ROUND(NVL(AJ.aj_state_adj_amt, 0.00) * (:p_ao_trx_fee/100), 2) END AS AO_Fee, 
     CASE WHEN AJ.aj_other_adj_amt IS NULL OR AJ.aj_other_adj_amt = 0.00 THEN 0.00 
    ELSE AJ.aj_other_adj_amt - ROUND(NVL(AJ.aj_state_adj_amt, 0.00) * (:p_ao_trx_fee/100), 2) END AS WDFW_Fee 
    FROM ADJUSTMENT AJ 
    JOIN ITEM IT ON IT.it_id = AJ.it_id 
    JOIN DISCOUNT_TYPE DT ON DT.di_id = IT.di_id 
    WHERE AJ.aj_status_ind = 'A' -- Include active adjustments only. 
    AND AJ.it_id IS NOT NULL -- Include Item Adjustments only; rows with a foreign key to the ITEM table are Item Adjustments. 
    AND AJ.ajt_id != '0' -- Unreturned Doc Charge is not an Item Adjustment, it's a Lump Sum Adjustment to the Dealers account. 
    AND IT.ic_rcn != '999' -- Exclude Dealer Fees. 
    AND AJ.aj_adjustment_date BETWEEN :P_beg_dt -- Pacific Time 
       AND :P_end_dt 
    AND (:p_discount_type IS NULL OR DT.di_id = :p_discount_type) 
    --AND AJ.Ajt_Adjustment_Type_Name = :SalesType 
) ReportDetails 

    WHERE  Sales_Type = :p_sales_type 
       AND (:p_ic_rcn is null OR :p_ic_rcn = Item_Number) 
       AND (:p_dealer_id IS NULL OR Dealer_ID = :p_dealer_id) 




    ORDER BY TO_DATE(SUBSTR(Transaction_Date,1,10), 'MM/DD/YYYY'), Item_Number, -- Transaction Date, RCN (numerical order), order RCN was purchased. 
     TO_CHAR(TO_DATE(Transaction_Date, 'MM/DD/YYYY HH24:MI:SS'), 'SSSSS'); 

    END IF; 
+2

実際のエラーコードと声明はどうなりますか? PL/SQL文脈では、これらのSQL文には 'SELECT .. INTO ..'やその他の処理方法が必要です。 – Wolf

+0

どのようなORAエラー番号を取得していますか? – Ollie

+0

エラー24333 @Ollie – RageQwit

答えて

3

は、私はあなたが「ゼロ反復回数」によって何を意味するかわからないが、あなたはにあなたの結果を選択し、ELSIFむしろELSE IFよりも使用するようにINTO句を必要とする:あなたは、スプリアスを持って

IF :p_sales_type = 'all_cancel' 
THEN 
    SELECT col_list 
    INTO variable_list 
    FROM tables 
    WHERE <where_clause>; 
ELSIF :p_sales_type = 'item_adjustment' 
THEN 
    SELECT col_list 
    INTO variable_list 
    FROM tables 
    WHERE <where_clause>; 
ELSIF :p_sales_type IS NULL 
THEN 
    SELECT col_list 
    INTO variable_list 
    FROM tables 
    WHERE <where_clause>; 
ELSE 
    SELECT col_list 
    INTO variable_list 
    FROM tables 
    WHERE <where_clause>; 
END IF; 

あなたのp_sales_type変数/パラメータの前にコロンを置きます。 最後に、UPPERにをラップしてUPPER(p_sales_type) = 'ALL_CANCEL'としておくと、(値の大文字小文字が間違っていない限り)意図しないミスマッチがないことを確認する価値があります。

希望します。

+0

コロンは、Oracleレポートのパラメータであり、IFを追加するまで正常に動作していたためです@Ollie – RageQwit

+0

十分な場合は、Oracle Reports変数の場合はコロンを保持する必要があります。 – Ollie