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

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: (view raw, whole thread or download thread mbox)
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.


In response to

pgsql-general by date

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

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