On Mon, 24 Jan 2005, William Yu wrote:
> If you absolutely need the display field to be unique and it has to be a
> sequence starting from 1 -- it's simplicity itself. Use the
> serialization errors to your advantage. If you try to insert a record
> and you get a dupe key violation, just increment
On Sun, 23 Jan 2005, William Yu wrote:
> Ralph van Etten wrote:
> > I agree that a serial would be better.
> >
> > But I think there are situations where a serial isn't convenient
> > Like when you want an primary key which consists of the current
> > year
On Sat, 22 Jan 2005, Tino Wildenhain wrote:
> > INSERT INTO test (id, name)
> > SELECT COALESCE(MAX(id)+1, 1), 'name' FROM test
> >
> > Ofcourse this gives problems when two clients are inserting a record at
> > the same time. (duplicate primary keys) But, i can't use a sequence in my
> > applicat
Hoi,
I searched the archives but couldn't find an answer to this:
I have a table (simplyfied)
CREATE TABLE test (
id INT PRIMARY KEY,
name VARCHAR(250)
);
I insert records with
INSERT INTO test (id, name)
SELECT COALESCE(MAX(id)+1, 1), 'name' FROM test
Ofcourse this gives problems when