Re: How to check: is some key referenced from sometable

From: eVl One <evl(at)my-mail(dot)com(dot)ua>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to check: is some key referenced from sometable
Date: 2003-08-09 21:44:32
Message-ID: 18618711976.20030810004432@my-mail.com.ua
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello, Bruno.

You wrote 9 08 2003, 18:08:09:

BWI> On Mon, Aug 04, 2003 at 11:17:56 +0300,
BWI> evl(at)my-mail(dot)com(dot)ua wrote:
>> Please help.
>>
>> Need a boolean function which returns true if given key in table is
>> referensed from another table(s).

BWI> Use "exists" with a subselect. Something like:
BWI> select exists(select 1 from table where table.key = 'value');

Thanx for advice, but way I know and it can't be used.
That's why I've got too many and/or too big tables from which
such key is referenced. I mean (in some simplified way):

table A ( -- main table A
id SERIAL,
PRIMARY KEY(id)
);

tableBxx ( -- a lot of tables which got a.id as FOREIGN KEY
... -- too much to check 'em all with EXISTS queries
a_id int4 REFERENCES a(id), -- without significant perfomance loss
...
);

So I need:
"silent delete" - i.e. when trying to DELETE row from A I'll not fall
out with "$1 referential integrity violation - key in A still
referenced from Bxx", but silently doesn't delete row ('cause run
it from function and need function to executes farther after delete);
"something to check reference" - system (potgresql) is very quickly
realizes that key is referenced from another table, maybe this
information may be accessed through some system relations, or so?
Thanx for attention.

--
Best regards,
eVl

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message sebmil 2003-08-10 03:13:42 Re: Retrieving tuple data on insert
Previous Message Joe Conway 2003-08-09 16:01:13 Re: Comparing arrays