Test for cascade delete in plpgsql

From: Robert Fitzpatrick <robert(at)webtent(dot)org>
To: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Test for cascade delete in plpgsql
Date: 2011-10-13 20:39:19
Message-ID: 4E974C77.3060402@webtent.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

My contacts table has a FK with cascade delete to foreign table
companies using the company_id column.

I have a DELETE AFTER trigger on my contacts table that checks to see if
there are any contacts left with an email address or it won't allow you
to delete the record for a company. However, if the company is being
deleted, is there a way I can test for the cascade delete reason and
have my trigger allow the contact to be deleted?

--Robert

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bob Hatfield 2011-10-13 21:07:03 Re: pg 8.3 replication causing corruption
Previous Message Evan Walter 2011-10-13 20:31:28 Re: Trying to use binary replication - from tutorial