Re: How to enforce the use of the sequence for serial columns

From: "Marc Mamin" <M(dot)Mamin(at)intershop(dot)de>
To: "Jerry Sievers" <jerry(at)jerrysievers(dot)com>, "Ben K(dot)" <bkim(at)coe(dot)tamu(dot)edu>
Cc: <pgsql-admin(at)postgresql(dot)org>
Subject: Re: How to enforce the use of the sequence for serial columns
Date: 2006-12-14 12:45:45
Message-ID: CA896D7906BF224F8A6D74A1B7E54AB3198766@JENMAIL01.ad.intershop.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin


> It's not a full solution anyway since it prevents any kind of update
on the table due to check constraints firing even if target field not
updated. >

Well, we can extend the check within the trigger:

if (coalesce old.a=new.a -- Update
OR
new.a = currval(tg_argv[0] -- Insert
) then
return new;
end if;

Marc

Browse pgsql-admin by date

  From Date Subject
Next Message Ben K. 2006-12-14 14:10:14 Re: How to enforce the use of the sequence for serial columns
Previous Message Jerry Sievers 2006-12-14 12:30:46 Re: How to enforce the use of the sequence for serial columns