Re: get sequence value of insert command

From: Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: Erik Thiele <erik(at)thiele-hydraulik(dot)de>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: get sequence value of insert command
Date: 2004-11-19 09:37:53
Message-ID: Pine.LNX.4.44.0411191136220.13400-100000@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

O Erik Thiele έγραψε στις Nov 19, 2004 :

> hi
>
> create sequence mysequence;
>
> create table foo(
> id integer default nextval('mysequence'),
> bla text,
> wombat integer,
> foobar date,
> primary key(id)
> );
>
> insert into foo (wombat) values (88);
>
> now how do i know the id of my newly inserted element? and
> how can this be done in a completely concurrency safe way?

The way to do this is by reading the docs :)

use currval, it is session safe.

>
>
> cya
> erik
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>

--
-Achilleus

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Iain 2004-11-19 09:49:16 Re: get sequence value of insert command
Previous Message Richard Huxton 2004-11-19 09:26:52 Re: get sequence value of insert command