pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Achilleus Mantzios <achill@matrix.gatewaynet.com>
To: Erik Thiele <erik@thiele-hydraulik.de>
Cc: pgsql-sql@postgresql.org
Subject: Re: get sequence value of insert command
Date: Fri, 19 Nov 2004 11:37:53 +0200 (EET)
Message-ID: <Pine.LNX.4.44.0411191136220.13400-100000@matrix.gatewaynet.com> (raw)
In-Reply-To: <20041119094134.2437d867.erik@thiele-hydraulik.de>

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




view thread (8+ messages)  latest in thread

Message-ID: <Pine.LNX.4.44.0411191136220.13400-100000@matrix.gatewaynet.com>
Permalink:  ../Pine.LNX.4.44.0411191136220.13400-100000@matrix.gatewaynet.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.44.0411191136220.13400-100000@matrix.gatewaynet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: achill@matrix.gatewaynet.com, erik@thiele-hydraulik.de
  Subject: Re: get sequence value of insert command
  In-Reply-To: <Pine.LNX.4.44.0411191136220.13400-100000@matrix.gatewaynet.com>
  References: <20041119094134.2437d867.erik@thiele-hydraulik.de> <Pine.LNX.4.44.0411191136220.13400-100000@matrix.gatewaynet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox