Re: [SQL] Insert Data and autonumeric field

2007-02-01 Thread Tom Lane
=?iso-8859-1?Q?Andr=E9_Jos=E9_Guergolet?= <[EMAIL PROTECTED]> writes: > INSERT INTO table1 (date, field2, field3) VALUES > (now,'value2','value3'); > SELECT last_value FROM seq_table1; You should never ever look directly at the sequence table (except perhaps for manual

Re: [SQL] Insert Data and autonumeric field

2007-02-01 Thread Andrew Sullivan
On Thu, Feb 01, 2007 at 04:09:22PM -0300, André José Guergolet wrote: > PROBLEM: Many clients are getting duplicated IDs. > > What is the best way of doing this? Use a sequence. You can get the current value of the sequence with SELECT currval('seqname'). No, there's not a race condition; see t