generate_series() equivalent in DB2

ⅰ亾dé卋堺 提交于 2019-11-30 13:17:35

The where clause needs to be a bit more explicit about the bounds of the recursion in order for DB2 to suppress the warning. Here's a slightly adjusted version that does not trigger the warning:

with dummy(id) as (
    select 2 from SYSIBM.SYSDUMMY1    
    union all
    select id + 1 from dummy where id < 4
)
select id from dummy

I managed to write a recursive query that fits :

with dummy(id) as (
    select 2 from SYSIBM.SYSDUMMY1    
    union all
    select id + 1 from dummy where id + 1 between 2 and 4
)
select id from dummy

The query can be adapted to whatever for(;;) you can dream of.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!