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

Serial and triggers

From: Lan Barnes <lan(at)falleagle(dot)net>
To: Postgres Newbie <pgsql-novice(at)postgresql(dot)org>
Subject: Serial and triggers
Date: 2006-09-08 22:41:15
Message-ID: 20060908224115.GA20121@falleagle.net (view raw or flat)
Thread:
Lists: pgsql-novice
I have come to the conclusion that the serial data type is inadequate
for providing a reliable unique record number on inserts. The final
sticking point is that after restoring (or replicating) a data base from
a pg_dump, the seed number for the serial value isn't updated and I get
dupe numbers.

To compensate for this, I want to add a code snippet on inserts that
checks for the high number in the unique number field, increments it,
and inserts. However, it seems to me that this snippet should be an
insert trigger so that I don't have to promulgate it to all clients,
present and future.

Because this is NOVICE I have no trouble admitting I have no trigger
experience. However, before I get into it, I want to ask if this is
already available on some contrib forum.

TIA,

-- 
Lan Barnes
Linux Guy, SCM Specialist     
Tcl/Tk Enthusiast 

Let me take this opportunity to dispel the notion, the canard,
that scientists are against transcendentalism, ... particularly
intelligent design. If any positive evidence could be found of a
supernatural guiding force, there would be a land rush of
scientists into it.
                          - Edward O. Wilson


Responses

pgsql-novice by date

Next:From: Steve CrawfordDate: 2006-09-09 00:11:01
Subject: Re: Serial and triggers
Previous:From: Karen HillDate: 2006-09-08 21:48:13
Subject: Re: Insert Only Postgresql

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