pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephen van Egmond <svanegmond@bang.dhs.org>
To: Julio Cuz, Jr. <jcuz@rccd.cc.ca.us>
Cc: pgsql-php@postgresql.org
Subject: Re: Automatic increment
Date: Thu, 11 Jan 2001 22:22:05 -0500
Message-ID: <20010111222205.A31717@bang.dhs.org> (raw)
In-Reply-To: <4.3.2.7.2.20010111190805.00b4b6a0@rccd.cc.ca.us>
References: <4.3.2.7.2.20010111190805.00b4b6a0@rccd.cc.ca.us>

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.




view thread (7+ messages)  latest in thread

Message-ID: <20010111222205.A31717@bang.dhs.org>
Permalink:  ../20010111222205.A31717@bang.dhs.org/
Also on:    postgresql.org/message-id/20010111222205.A31717@bang.dhs.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: svanegmond@bang.dhs.org, jcuz@rccd.cc.ca.us, pgsql-php@postgresql.org
  Subject: Re: Automatic increment
  In-Reply-To: <20010111222205.A31717@bang.dhs.org>
  References: <4.3.2.7.2.20010111190805.00b4b6a0@rccd.cc.ca.us> <20010111222205.A31717@bang.dhs.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox