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/