From: Josh Berkus <josh@agliodbs.com>
To: Christoph Haller <ch@rodos.fzk.de>
To: intrnl_edu@ilyichevsk.odessa.ua
Cc: pgsql-sql@postgresql.org
Subject: Re: extend INSERT by 'INSERT INTO table FETCH ... FROM cursor' syntax
Date: Mon, 27 Oct 2003 11:35:58 -0800
Message-ID: <200310271135.59460.josh@agliodbs.com> (raw)
In-Reply-To: <200310271539.QAA10042@rodos>
References: <200310271539.QAA10042@rodos>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: josh@agliodbs.com, ch@rodos.fzk.de, intrnl_edu@ilyichevsk.odessa.ua
Subject: Re: extend INSERT by 'INSERT INTO table FETCH ... FROM cursor' syntax
In-Reply-To: <200310271135.59460.josh@agliodbs.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox