Hello.
v8.2.
Is it possible?
Example:
---------------
create function t(v varchar(1))
modifies sql data
returns table(c varchar(1))
begin atomic
return select v from sysibm.sysdummy1;
end@
declare global temporary table session.test(c varchar(1)) on commit
preserve rows@
---------------
Now I have tried:
---------------
1.
insert into session.test select c from table(t('1')) as f;
--- SQL20267, Reason Code=2
2.
insert into session.test
with a(c) as (select c from table(t('1')) as f)
select c from a;
--- SQL20165
3.
begin atomic
for g as
with a(c) as (
select c from table(t('1')) as f
)
select c from a
do
insert into session.test values (g.c);
end for;
end@
--- SQL0901 (known bug)
---------------
Sincerely,
Mark B.
Serge Rielau - 22 Jun 2006 12:12 GMT
> Hello.
>
[quoted text clipped - 35 lines]
> --- SQL0901 (known bug)
> ---------------
Try this:
WITH a AS (SELECT c1 FROM TABLE(FOO()) AS F),
b AS (SELECT 1 AS X FROM NEW TABLE(INSERT INTO T SELECT * FROM a))
SELECT COUNT(1) FROM b
The WITH has to be on the outside. And WITH today in DB2 can only be
outside preceding a query.
Cheers
Serge

Signature
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
IOD Conference
http://www.ibm.com/software/data/ondemandbusiness/conf2006/
4.spam@mail.ru - 22 Jun 2006 12:52 GMT
Thanks, Serge.
It works.
> > Hello.
> >
[quoted text clipped - 53 lines]
> IOD Conference
> http://www.ibm.com/software/data/ondemandbusiness/conf2006/