From: | Josh Berkus <josh(at)agliodbs(dot)com> |
---|---|
To: | Christoph Haller <ch(at)rodos(dot)fzk(dot)de>, intrnl_edu(at)ilyichevsk(dot)odessa(dot)ua |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: extend INSERT by 'INSERT INTO table FETCH ... FROM cursor' syntax |
Date: | 2003-10-27 19:35:58 |
Message-ID: | 200310271135.59460.josh@agliodbs.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-sql |
Alexander,
> > BEGIN;
> > DECLARE total CURSOR
> > FOR SELECT=20
> > SUBSTR(datetime,1,7)||'-01 00:00:00' as month,
> > client,
> > SUM(money)
> > FROM stat
> > WHERE SUBSTR(datetime,1,7)=3D'2003-10'
> > GROUP BY month,client;
> > DELETE FROM stat WHERE SUBSTR(datetime,1,7)=3D'2003-10';
> > INSERT INTO stat FETCH ALL FROM total;
> > COMMIT;
> >
> > but it does not work, chokes on FETCH ALL.
Well, there's two problems with your program:
1) INSERT INTO .... FETCH ALL is not currently implemented. You would need to
use a loop, and insert one row at a time by value.
2) You can't insert the rows you've just deleted from the base tables. In
your example, the TOTAL cursor would be empty. I think that what you really
want is a temp table.
--
-Josh Berkus
Aglio Database Solutions
San Francisco
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Stark | 2003-10-27 19:39:43 | Re: Recomended FS |
Previous Message | Bruce Momjian | 2003-10-27 19:14:41 | Re: SCSI vs. IDE performance test |
From | Date | Subject | |
---|---|---|---|
Next Message | Tomasz Myrta | 2003-10-27 19:48:54 | Re: Error with DROP column |
Previous Message | mohan | 2003-10-27 19:35:44 | Error with DROP column |