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

Re: Unable to Delete a Row

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Derrick Betts" <derrick(at)grifflink(dot)com>
Cc: "Kevin Crenshaw" <kcrenshaw(at)tiewireinc(dot)com>,pgsql-novice(at)postgresql(dot)org
Subject: Re: Unable to Delete a Row
Date: 2005-05-25 21:25:52
Message-ID: 2474.1117056352@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-novice
"Derrick Betts" <derrick(at)grifflink(dot)com> writes:
> I think that you need to "RETURN NEW;" in your tg_remove_contact()
> function rather than "RETURN NULL;"

Actually, since it's a DELETE trigger, there is no NEW row;
he needs to RETURN OLD, instead, to give permission for the delete
to continue.

Given what the trigger is doing (ie, propagating the update to another
table), he might be better off to use an AFTER DELETE trigger instead
of BEFORE DELETE anyway --- in which case the return value doesn't
matter and so RETURN NULL is fine.  The point of AFTER DELETE is that
you can be certain the delete really did happen, and wasn't cancelled
by some other BEFORE DELETE trigger.

			regards, tom lane

In response to

pgsql-novice by date

Next:From: MohammadDate: 2005-05-25 23:44:45
Subject: Important News
Previous:From: Glauter Moulin CoelhoDate: 2005-05-25 17:29:29
Subject: Re: Migration from MySQL

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