我必須將FlightDate
,FlightNumbers
作爲參數傳遞給Oracle存儲過程,如下所示。如何在Oracle存儲過程中獲取逗號分隔值
CREATE OR REPLACE PROCEDURE GetPaxDetails(
FlyingDate IN PAX_DETAILS.FlightDate%TYPE,
FlightNumbers IN VARCHAR(300))
IS
BEGIN
-- Assume that we've received **FlightNumbers** as '0620,0712,0154'
-- Basically I am trying to select all passenger details (PAX_DETAILS)
-- for those flights passed in as a parameter(**FlightNumbers**)
-- for the specified dates
-- In this procedure the query should be generated something like below:
SELECT *
FROM PAX_DETAILS
WHERE TO_DATE(FlightDate,'DDMONYY') BETWEEN TO_DATE(FlyingDate,'DDMONYY')
AND TO_DATE(FlyingDate,'DDMONYY') + 1
AND FlightNo IN ('0620,0712,0154')
END
我不理解如何FlightNumbers
參數轉換爲類似AND FlightNo IN ('0620,0712,0154')
查詢裏面。
你嘗試過:SELECT * FROM PAX_DETAILS WHERE TO_DATE(FlightDate, 'DDMONYY')之間TO_DATE(FlyingDate, 'DDMONYY')和TO_DATE(FlyingDate, 'DDMONYY')+ 1和FlightNo IN( FlightNumbers) – Satya
你嘗試過使用動態sql嗎? : http://stackoverflow.com/questions/5007725/pl-sql-using-a-dynamic-query-inside-a-stored-procedure – planben
你可能會發現你的答案她:[發送一個值的數組到Oracle過程在WHERE IN子句中使用](http://stackoverflow.com/questions/13580245/sending-an-array-of-values-to-oracle-procedure-to-use-in-where-in-clause) –