From: | Alexander Vlasenko <intrnl_edu(at)ilyichevsk(dot)odessa(dot)ua> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | extend INSERT by 'INSERT INTO table FETCH ... FROM cursor' syntax |
Date: | 2003-10-23 21:00:00 |
Message-ID: | 200310240000.00608.intrnl_edu@ilyichevsk.odessa.ua |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-sql |
Please CC me, I am not subscribed.
An imaginary SQL statement
INSERT INTO table FETCH ... FROM cursor;
looks almost the same as currently available
INSERT INTO table SELECT ...;
I tried it because I needed to insert a row in a table
after I DELETEd a set of rows, something like this:
BEGIN;
DECLARE total CURSOR
FOR SELECT
SUBSTR(datetime,1,7)||'-01 00:00:00' as month,
client,
SUM(money)
FROM stat
WHERE SUBSTR(datetime,1,7)='2003-10'
GROUP BY month,client;
DELETE FROM stat WHERE SUBSTR(datetime,1,7)='2003-10';
INSERT INTO stat FETCH ALL FROM total;
COMMIT;
but it does not work, chokes on FETCH ALL.
I want to sum up all the money by month, delete all the rows
(possibly thousands of them) and insert one row per client
with monthly totals.
Obviously I cannot swap order of INSERT and DELETE here.
I hesitate to post this to pgsql-hackers(at)postgresql(dot)org,
do I have to? ;)
--
Alexander Vlasenko
From | Date | Subject | |
---|---|---|---|
Next Message | James Felix Black | 2003-10-23 21:49:57 | Re: Clustering for performance and fail over |
Previous Message | Mark Kirkwood | 2003-10-23 19:23:27 | Re: Recomended FS |
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2003-10-24 12:31:26 | Re: Error message during compressed backup |
Previous Message | Julian North | 2003-10-23 20:30:59 | naming conventions constraint |