Skip site navigation (1) Skip section navigation (2)

Re: getting a sequence value

From: Guillaume Cottenceau <gc(at)mnc(dot)ch>
To: pg(at)fastcrypt(dot)com
Cc: Nico <nicohmail-postgresql(at)yahoo(dot)com>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: getting a sequence value
Date: 2005-03-21 12:37:44
Message-ID: 87acoxuqcn.fsf@meuh.mnc.ch (view raw or flat)
Thread:
Lists: pgsql-jdbc
Dave Cramer <pg 'at' fastcrypt.com> writes:

> 2)
> allow the insert to go through
> select currval('public."tblTable1_FieldID_seq"'::text)
> and then use this to insert into table 2
> 
> FYI currval does the "right" thing. It is guaranteed to be the value
> your connection retrieved from the sequence.

Which can be wrong in case of multithreaded applications without
synchronization over the two requests, if I'm correct.

-- 
Guillaume Cottenceau

In response to

Responses

pgsql-jdbc by date

Next:From: Roland WalterDate: 2005-03-21 12:39:23
Subject: Re: getting a sequence value
Previous:From: Dave CramerDate: 2005-03-21 12:28:42
Subject: Re: getting a sequence value

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group