Re: [GENERAL] Trigger or Rule?

From: Adriaan Joubert <a(dot)joubert(at)albourne(dot)com>
To: Andy Lewis <alewis(at)themecca(dot)net>, pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] Trigger or Rule?
Date: 1999-04-26 13:33:24
Message-ID: 37246B24.6C4BC4C3@albourne.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Statistical Solutions 1999-04-26 13:51:24 Re: [GENERAL] advice on buying sun hardware to run postgres
Previous Message Adriaan Joubert 1999-04-26 13:22:08 Re: [GENERAL] Trigger or Rule?