mirof007 wrote:
It's possible today. Try the following:
with tmp1 as (select * from new table(insert into t1 values 1,2,3)
tmp3),
tmp2 as (select * from new table(insert into t2 select * from tmp1)
tmp4)
select count(*) from tmp4
Ah, yes that will do. A little typo though, I think it should be:
with tmp1 as (select * from new table(insert into t1 values 1,2,3)
tmp3),
tmp2 as (select * from new table(insert into t2 select * from tmp1)
tmp4)
select count(*) from tmp2
Also, I think the 2 CTE is unnecessary, because the following works:
# create table
db2 "create table T1 (c1 int not null primary key, c2 int not null
default 0)"
# some init data
db2 "insert into T1 (c1) with T (c1) as (values 0 union all select c1+1
from T where c1 < 5) select c1 from T"
# add some more
db2 "with tmp1 as (select * from new table(update t1 set c2 = c2+1
where mod(c1,2) = 0) tmp3) select * from new table(insert into t1
select c1+10,c2 from tmp1) tmp4"
C1 C2
----------- -----------
10 1
12 1
14 1
[ltjn@lelles ~/install/ddl/bin]$ db2 "select * from T1"
C1 C2
----------- -----------
0 1
1 0
2 1
3 0
4 1
5 0
10 1
12 1
14 1
Next step will be to squeze in the merge, now that will be one hell of
a stmt :-)
Thanx a lot for pointing this out
/Lennart
[...]