我能夠在TSQL中獲得類似的功能,但我是PL/SQL的相對新手,我希望有人能向我解釋爲什麼會這樣函數聲明不會編譯。
t_interval_list_table是具有varchar2(20)的單個屬性的對象t_interval的表類型。 Interval_Get_udf只是返回類型爲varchar(2)Oracle:從內聯表函數返回CTE的結果集
create or replace
FUNCTION fn_ExplodeIntervals (
startTime IN timestamp,
endTime IN timestamp,
inputInterval IN int)
RETURN t_interval_list_table AS intervalList t_interval_list_table := t_interval_list_table()
BEGIN
with SET0 as(select 1 from dual union all select 1 from dual)
, SET1 as (select 1 from SET0 s1, SET0 s2)
, SET2 as (select 1 from SET1 s1, SET1 s2)
, SET3 as (select 1 from SET3 s1, SET3 s2)
, SET4 as (select 1 from SET4 s1, SET4 s2)
, ControlSet AS (SELECT ROW_NUMBER() OVER(ORDER BY (SELECT 1 from Dual)) rid FROM SET4)
select t_interval(Interval_Get_udf(TO_TIMESTAMP(startTime, 'dd/mm/yyyy') + rid/24 , 1))
into intervalList
from ControlSet;
RETURN intervalList;
END fn_ExplodeIntervals;
你介意在問題中添加錯誤信息嗎? – Codo