Re: Return the primary key of a newly inserted row?

From: Alban Hertroys <alban(at)magproductions(dot)nl>
To: John Tregea <john(at)debraneys(dot)com>
Cc: Scott Ribe <scott_ribe(at)killerbytes(dot)com>, Kenneth Downs <ken(at)secdat(dot)com>, Tim Allen <tim(at)proximity(dot)com(dot)au>, pgsql-general(at)postgresql(dot)org
Subject: Re: Return the primary key of a newly inserted row?
Date: 2006-06-26 09:31:32
Message-ID: 449FA974.7060205@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

John Tregea wrote:
> The example of
>
> select id1 = nextval(somesequence)
>
> could work for me. I have multiple users with our GUI and imagine I
> could use transaction protection to ensure no duplicates between
> selecting and incrementing the somesequence...

You won't have duplicates[1], it's a sequence. It's its purpose.

Now I may have missed something, I didn't follow this thread.

[1] Unless you manage to make it wrap around after 2^32 (or 2^64?) calls
of nextval. But that's quite unlikely.
--
Alban Hertroys
alban(at)magproductions(dot)nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede

// Integrate Your World //

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message pajai 2006-06-26 09:52:56 limit over attribute size if index over it exists
Previous Message Bruno Baguette 2006-06-26 07:43:43 Re: "Ghost" colmumn with primary key