使用Oracle 11g第2版,以下查询给出了ORA-01790:表达式必须与相应的表达式具有相同的数据类型:
with intervals(time_interval) AS
(select trunc(systimestamp)
from dual
union all
select (time_interval + numtodsinterval(10, 'Minute'))
from intervals
where time_interval < systimestamp)
select time_interval from intervals;
Run Code Online (Sandbox Code Playgroud)
该错误表明UNION ALL的两个子查询的数据类型都返回不同的数据类型.
即使我在每个子查询中转换为TIMESTAMP,我也会得到相同的错误.
我错过了什么?
编辑:我不是在寻找CONNECT BY替代品.
源表如下:
Id start_date end_date field1
1 01/03/2019 07/03/2019 text1
2 10/04/2019 15/04/2019 text2
Run Code Online (Sandbox Code Playgroud)
我想得到以下输出:
Id date field1
1 01/03/2019 text1
1 02/03/2019 text1
1 03/03/2019 text1
1 04/03/2019 text1
1 05/03/2019 text1
1 06/03/2019 text1
1 07/04/2019 text1
2 10/04/2019 text2
2 11/04/2019 text2
2 12/04/2019 text2
2 13/04/2019 text2
2 14/04/2019 text2
2 15/04/2019 text2
Run Code Online (Sandbox Code Playgroud)
我必须使用循环来填充此表吗?
谢谢