Re: RETURNING, CTEs and TRANSACTION ISOLATION levels...

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: RETURNING, CTEs and TRANSACTION ISOLATION levels...
Дата
Msg-id 1885899.1621006807@sss.pgh.pa.us
обсуждение исходный текст
Ответ на RETURNING, CTEs and TRANSACTION ISOLATION levels...  (Pól Ua Laoínecháin <linehanp@tcd.ie>)
Список pgsql-general
=?UTF-8?B?UMOzbCBVYSBMYW/DrW5lY2jDoWlu?= <linehanp@tcd.ie> writes:
> I was trying to do this:

> DELETE FROM t
> WHERE id IN
>   INSERT INTO t_archiv
>   (
>     SELECT *
>     FROM t
>     WHERE EXTRACT(EPOCH FROM NOW()) - epok > 15613200
>   )
>   RETURNING id;

Try putting the INSERT ... RETURNING in a CTE (WITH clause).
We don't support putting RETURNING into any random place
where a sub-select can appear, because the semantics would
be too unpredictable.  But a WITH has guaranteed evaluate-once
semantics, so DML with RETURNING is OK there.

(Maybe something more specific than a syntax error would
be nice ...)

            regards, tom lane



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

Предыдущее
От: Pól Ua Laoínecháin
Дата:
Сообщение: RETURNING, CTEs and TRANSACTION ISOLATION levels...
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: RETURNING, CTEs and TRANSACTION ISOLATION levels...