Re: extend INSERT by 'INSERT INTO table FETCH ... FROM cursor' syntax

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: extend INSERT by 'INSERT INTO table FETCH ... FROM cursor' syntax
Дата
Msg-id 200310271135.59460.josh@agliodbs.com
обсуждение исходный текст
Ответ на Re: extend INSERT by 'INSERT INTO table FETCH ... FROM cursor' syntax  (Christoph Haller <ch@rodos.fzk.de>)
Ответы Re: extend INSERT by 'INSERT INTO table FETCH ... FROM cursor' syntax  (Alexander Vlasenko <intrnl_edu@ilyichevsk.odessa.ua>)
Список 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 BerkusAglio Database SolutionsSan Francisco



В списке pgsql-sql по дате отправления:

Предыдущее
От: Gary Stainburn
Дата:
Сообщение: Re: URGENT!!! changing Column size
Следующее
От: Tomasz Myrta
Дата:
Сообщение: Re: URGENT!!! changing Column size