> -----Original Message-----
> From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-
> ow...@postgresql.org] On Behalf Of Victor Sterpu
> Sent: Friday, October 19, 2012 2:15 PM
> To: pgsql-sql@postgresql.org
> Subject: [SQL] Trigger triggered from a foreign key
> 
> I have this trigger that works fine. The trigger prevents the deletion of
the
> last record.
> But I want skip this trigger execution when the delete is done from a
external
> key.
> How can I do this?
> 

I do not think this is possible; there is no "stack" context to examine to
determine how a DELETE was issued.

The trigger itself would seem to be possibly exhibit concurrency issues,
meaning that in certain circumstances the last record could be deleted.  You
may want to add explicit locking to avoid that possibility.  That or figure
out a better way to accomplish whatever it is you are trying to do.

David J.




-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply via email to