Thread: REFERENCES Constraint

REFERENCES Constraint

From
Pavel Fryc
Date:
Hi,

Is there a way to find out for given row and column what other tables/rows
reference this row/column by means of reference integrity. I need this when
user deletes number of rows from a table and there is integrity violation I
want to get a list of tables/rows that cause the violation for user to
review.
I need help from You with this my problem.

Best regards, Pavel Fryc

Re: REFERENCES Constraint

From
Stephan Szabo
Date:
On Wed, 18 Jul 2001, Pavel Fryc wrote:

> Is there a way to find out for given row and column what other tables/rows
> reference this row/column by means of reference integrity. I need this when
> user deletes number of rows from a table and there is integrity violation I
> want to get a list of tables/rows that cause the violation for user to
> review.
> I need help from You with this my problem.

It's not really easy, you need to get the references information out of
pg_trigger (see the archives for more information) and then given that
you could probably formulate the query necessary to get the rows (you'd
probably want to look at backend/utils/adt/ri_triggers.c at the noaction
triggers for information on how to make the query).