Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / June 2006

Tip: Looking for answers? Try searching our database.

Insert select from SQL table function that modifies sql data

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
4.spam@mail.ru - 22 Jun 2006 06:56 GMT
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/
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.