Re: serialization errors when inserting new records - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: serialization errors when inserting new records
Date
Msg-id 20050123111258.GA13120@wolff.to
Whole thread Raw
In response to Re: serialization errors when inserting new records  (Ralph van Etten <ralph@et10.org>)
List pgsql-general
On Sun, Jan 23, 2005 at 10:23:50 +0100,
  Ralph van Etten <ralph@et10.org> wrote:
> 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 and an sequence number. Like ('05', 1), ('05', 2), ('05', 3) etc.
> With a sequence you must write extra code to reset the sequence every year
> and you get into trouble if someone inserts data from the previous year...
> A 'MAX(id)+1' is much simpler and cleaner then.

You don't normally want to do that either. You should use one sequence for all
of the years.

pgsql-general by date:

Previous
From: Ralph van Etten
Date:
Subject: Re: serialization errors when inserting new records
Next
From: William Yu
Date:
Subject: Re: serialization errors when inserting new records