zOs/SQL/EXFUTB

set current sqlid = 'S100447';
drop   function A540769.tst012(timestamp, timestamp)
;
create function A540769.tst012(t1 timestamp, t2 timestamp)
    returns table (t timestamp)
    language sql  deterministic called on null input
    reads sql data
 return
    select t1 from sysibm.sysDummy1 where t1 is not null
    union all select t2 from sysibm.sysDummy1 where t2 is not null
;
select * from table(
    A540769.tst012(current timestamp, current timestamp + 1 month)
    ) a
;
select * from table(
    A540769.tst012(timestamp(current date), current timestamp + 1 month)
    ) a
;
select * from table(
    A540769.tst012(timestamp(current date), case when 1=0
            then current timestamp else null end)
    ) a
;x;
drop   function A540769.one2n( int);
create function A540769.one2n(cnt int)
    returns table (n int)
    language sql  deterministic reads sql data
  return
  with rr (n) as
  (
     select 1 from sysibm.sysDummy1 where cnt >= 1
     union all select n+1 from rr where n < cnt
  )
  select * from rr
;
select * from table(A540769.one2n(5)) a ;
select * from table(A540769.one2n(0)) a ;
select * from table(A540769.one2n(1)) a ;

          with view infinite loop ||||||||||||||||
with rr (n) as
  (
     select 1 from sysibm.sysDummy1
     union all select n+1 from rr
  )
  select * from rr where n < 5