[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-general
Subject:    Re: [GENERAL] Trigger or Rule?
From:       Adriaan Joubert <a.joubert () albourne ! com>
Date:       1999-04-26 13:33:24
[Download RAW message or body]

> 
> 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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic