Received: from cr322781-a.ym1.on.wave.home.com (cr322781-a.ym1.on.wave.home.com [24.112.37.89]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0C3ISp77400 for ; Thu, 11 Jan 2001 22:18:28 -0500 (EST) (envelope-from svanegmond@bang.dhs.org) Received: from svanegmond by cr322781-a.ym1.on.wave.home.com with local (Exim 3.20 #1 (Debian)) id 14Gumz-0008Fg-00; Thu, 11 Jan 2001 22:22:05 -0500 Date: Thu, 11 Jan 2001 22:22:05 -0500 To: "Julio Cuz, Jr." Cc: pgsql-php@postgresql.org Subject: Re: Automatic increment Message-ID: <20010111222205.A31717@bang.dhs.org> Reply-To: svanegmond@home.com References: <4.3.2.7.2.20010111190805.00b4b6a0@rccd.cc.ca.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <4.3.2.7.2.20010111190805.00b4b6a0@rccd.cc.ca.us>; from jcuz@rccd.cc.ca.us on Thu, Jan 11, 2001 at 07:09:08PM -0800 From: Stephen van Egmond X-Archive-Number: 200101/43 X-Sequence-Number: 108 Julio Cuz, Jr. (jcuz@rccd.cc.ca.us) wrote: > Some of you guys suggested to use the 'SERIAL' type for a field that needs > to be AUTOMATICALLY INCREASED BY 1 by PGSQL without user intervention, but > it doesn't seem to work. What am I doing wrong? Though I wasn't here for that, here's how I normally declare automatically-incrementing values: CREATE SEQUENCE foo_id; CREATE TABLE foo ( foo_id integer not null primary key default nextval(foo_id); ... ); insertions to foo get their own unique ID. With the php extension, you can get the oid of the row that was inserted and go get the ID if you happen to need it.