Re: [GENERAL] Trigger or Rule? - Mailing list pgsql-general

From Adriaan Joubert
Subject Re: [GENERAL] Trigger or Rule?
Date
Msg-id 37246B24.6C4BC4C3@albourne.com
Whole thread Raw
In response to Trigger or Rule?  (Andy Lewis <alewis@themecca.net>)
List pgsql-general
>
> select count(*) into cnt from <tablename> where new.<key> = key;
> if (cnt>0) then
>         delete from <tablename> where key = new.<key>
> end if
>

Just looked at this, and this is not actually what you wanted. If you do
not want to replace the old row, do something along the lines

RAISE EXCEPTION ''Duplicate entry''

which will abort the insert. It's all in the manual.

Adriaan

pgsql-general by date:

Previous
From: Adriaan Joubert
Date:
Subject: Re: [GENERAL] Trigger or Rule?
Next
From: Statistical Solutions
Date:
Subject: Re: [GENERAL] advice on buying sun hardware to run postgres