Re: How to enforce the use of the sequence for serial columns - Mailing list pgsql-admin

From Marc Mamin
Subject Re: How to enforce the use of the sequence for serial columns
Date
Msg-id CA896D7906BF224F8A6D74A1B7E54AB3198766@JENMAIL01.ad.intershop.net
Whole thread Raw
List 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



pgsql-admin by date:

Previous
From: Jerry Sievers
Date:
Subject: Re: How to enforce the use of the sequence for serial columns
Next
From: "Ben K."
Date:
Subject: Re: How to enforce the use of the sequence for serial columns