Re: INSERT ... RETURNING as Oracle

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: INSERT ... RETURNING as Oracle
Дата
Msg-id Pine.LNX.4.30.0103042101140.757-100000@peter.localdomain
обсуждение исходный текст
Ответ на INSERT ... RETURNING as Oracle  ("Sipos Andras" <s-andras-nospam4@freemail.hu>)
Ответы Re: INSERT ... RETURNING as Oracle  ("Martin A. Marques" <martin@math.unl.edu.ar>)
Список pgsql-general
Sipos Andras writes:

> create table basket (
>   id   serial  NOT NULL PRIMARY KEY,
>   timestamp  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
> );
>
> How can I make a one step insert into the table and get values of 'ID' ?
> I am trying to find a similar solution as in the oracle's INSERT ...
> RETURNING.

We have this sort of thing on the wish list, but it doesn't exist yet.
Some people feel it's better to calculate the default in the client
program and insert it explicitly.  This may be a reasonable alternative
for some applications.

> If I use at first the INSERT, and after SELECT MAX(ID), the result will be
> uncertain.

If you are worried about other transactions getting in the way then you
should do SET TRANSACTION ISOLATION LEVEL SERIABLIZABLE.

--
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/


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

Предыдущее
От: "Sipos Andras"
Дата:
Сообщение: INSERT ... RETURNING as Oracle
Следующее
От: Louis-David Mitterrand
Дата:
Сообщение: Re: avoiding endless loop in an UPDATE trigger