Thread: ablilty to test record for foreign key before deleting the record?

ablilty to test record for foreign key before deleting the record?

From
Nathan Clark
Date:
Is there a way to check to see if a record has a foreign key, before I try to delete a record ?
To check first to see if this record is tied to a foreign key before I try to change it, thus avoiding
a foreign key error.

Re: ablilty to test record for foreign key before deleting the record?

From
"Jim C. Nasby"
Date:
On Tue, Nov 15, 2005 at 10:52:30AM -0600, Nathan Clark wrote:
> Is there a way to check to see if a record has a foreign key, before I
> try to delete a record ?
> To check first to see if this record is tied to a foreign key before I
> try to change it, thus avoiding
> a foreign key error.

Well, you could always try selecting on the child table...

What are you actually trying to do? If you just want to avoid exposing
the error you're probably better off just trapping for it in plpgsql.
--
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461