Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 7583E4760E9 for ; Mon, 6 May 2002 13:20:16 -0400 (EDT) Received: from bast.unixathome.org (bast.unixathome.org [216.187.105.150]) by postgresql.org (Postfix) with ESMTP id 6E14B476656 for ; Mon, 6 May 2002 12:41:32 -0400 (EDT) Received: from wocker (wocker.unixathome.org [192.168.0.99]) by bast.unixathome.org (Postfix) with ESMTP id 00EE03F43; Mon, 7 May 2001 08:43:41 -0400 (EDT) From: "Dan Langille" Organization: DVL Software Limited To: "Joel Burton" Date: Mon, 6 May 2002 12:41:24 -0400 MIME-Version: 1.0 Subject: Re: SERIAL Field Reply-To: dan@langille.org Cc: pgsql-admin@postgresql.org In-reply-to: References: <200205061856.10924.mallah@trade-india.com> X-mailer: Pegasus Mail for Windows (v4.01) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body Message-Id: <20010507124341.00EE03F43@bast.unixathome.org> X-Archive-Number: 200205/34 X-Sequence-Number: 4209 On 6 May 2002 at 10:51, Joel Burton wrote: > > But the very idea of inserting the value and then retriving the sequence > > number sounds fishy to me. Why not get the sequence number first and than > > insert using that seqnce number (more on the flash tutorial ). That's pretty standard in a number of database applications (i.e. not just PostgreSQL situations). > Hmmm... does nextval() 'hold' a sequence number for this backend? > Otherwise, the risk would be that you request a value, and someone else has > beat you to it before you insert it. I use nextval all the time. In fact: fp2migration=# \d users Column | Type | Modifiers ------------+--------------------------+-------------------------- id | integer | not null default nextval('users_id_seq'::text) What's wrong this this? Nobody is going to "beat me to it". > In any event, inserting then using currval() is the standard practice > around here, and it works great. Nothing fishy at all here, nothing to see, > move on. Why is that "less risk"? -- Dan Langille The FreeBSD Diary - http://freebsddiary.org/ - practical examples