Re: serialization errors when inserting new records

From: Gary Doades <gpd(at)gpdnet(dot)co(dot)uk>
To: Ralph van Etten <ralph(at)et10(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: serialization errors when inserting new records
Date: 2005-01-22 11:56:59
Message-ID: 41F23F8B.7090809@gpdnet.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ralph van Etten wrote:
> 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 two clients are inserting a record at
> the same time. (duplicate primary keys) But, i can't use a sequence in my
> application (the pk consists of more than just a sequence)
>

It's not clear why you can't use a serial as the primary key or as part
of the primary key. From your example it looks like you are trying to do
exactly that.

What does your *real* primary key consist of?

Cheers,
Gary.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Green 2005-01-22 12:57:06 Re: Data entry - forms design or other APIs etc. - what is there?
Previous Message Tino Wildenhain 2005-01-22 11:46:39 Re: serialization errors when inserting new records