Skip site navigation (1) Skip section navigation (2)

Re: serialization errors when inserting new records

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Ralph van Etten <ralph(at)et10(dot)org>
Cc: Postgresql-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: serialization errors when inserting new records
Date: 2005-01-23 11:12:58
Message-ID: 20050123111258.GA13120@wolff.to (view raw, whole thread or download thread mbox)
Thread:
Lists: pgsql-general
On Sun, Jan 23, 2005 at 10:23:50 +0100,
  Ralph van Etten <ralph(at)et10(dot)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.

In response to

pgsql-general by date

Next:From: Alvaro HerreraDate: 2005-01-23 14:35:48
Subject: Re: [GENERAL] Windows 2000 Slower Than Windows XP (SOLVED)
Previous:From: William YuDate: 2005-01-23 11:02:49
Subject: Re: serialization errors when inserting new records

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group