Re: [GENERAL] deleting a foreign key that has no references

2007-03-19 Thread Reece Hart
On Mon, 2007-03-19 at 13:03 -0700, Reece Hart wrote: > The harder and more general case is to build such a query dynamically > from pg_depends ... > See the pg_depends documentation at Apologies. I intended to write pg_constraint and the documentation at http://www.postgresql.org/docs/8.2/inte

Re: [GENERAL] deleting a foreign key that has no references

2007-03-19 Thread Reece Hart
On Mon, 2007-03-19 at 11:12 -0500, Glen W. Mabey wrote: > What I'm hoping to find out is whether there is some way to directly > find out how many (using a SELECT query) references there are to a > key. In the easy case when your schema doesn't change often, you can just hard code a query of the

Re: [GENERAL] deleting a foreign key that has no references

2007-03-19 Thread Glen W. Mabey
On Mon, Mar 19, 2007 at 09:46:22AM -0700, Stephan Szabo wrote: > On Mon, 19 Mar 2007, Glen W. Mabey wrote: > > > Hello, > > > > I'm using 8.1.8, and I have a situation where a record in one table is > > only meaningful when it is referenced via foreign key by one or more > > records in any one of

Re: [GENERAL] deleting a foreign key that has no references

2007-03-19 Thread hubert depesz lubaczewski
On 3/19/07, Glen W. Mabey <[EMAIL PROTECTED]> wrote: > write a triggers which do that. I understand that a trigger should be written, and I have already implemented two such triggers, as described above. no, i think i didn't make myself clear. let's use this situation: we have tables: create ta

Re: [GENERAL] deleting a foreign key that has no references

2007-03-19 Thread andyk
Glen W. Mabey wrote: On Mon, Mar 19, 2007 at 04:51:57PM +0100, hubert depesz lubaczewski wrote: On 3/19/07, Glen W. Mabey <[EMAIL PROTECTED]> wrote: I'm using 8.1.8, and I have a situation where a record in one table is only meaningful when it is referenced via foreign key by one or mor

Re: [GENERAL] deleting a foreign key that has no references

2007-03-19 Thread Tom Lane
"Glen W. Mabey" <[EMAIL PROTECTED]> writes: > What I'm hoping to find out is whether there is some way to directly > find out how many (using a SELECT query) references there are to a key. There's no hidden shortcut for that, no. regards, tom lane

Re: [GENERAL] deleting a foreign key that has no references

2007-03-19 Thread Stephan Szabo
On Mon, 19 Mar 2007, Glen W. Mabey wrote: > Hello, > > I'm using 8.1.8, and I have a situation where a record in one table is > only meaningful when it is referenced via foreign key by one or more > records in any one of several tables. > > So, really what I want is when one of the referring recor

Re: [GENERAL] deleting a foreign key that has no references

2007-03-19 Thread Glen W. Mabey
On Mon, Mar 19, 2007 at 04:51:57PM +0100, hubert depesz lubaczewski wrote: > On 3/19/07, Glen W. Mabey <[EMAIL PROTECTED]> wrote: > >I'm using 8.1.8, and I have a situation where a record in one table > >is > >only meaningful when it is referenced via foreign key by one or more > >records in any on

Re: [GENERAL] deleting a foreign key that has no references

2007-03-19 Thread hubert depesz lubaczewski
On 3/19/07, Glen W. Mabey <[EMAIL PROTECTED]> wrote: But, really, I just want to be able to test to see how many references there are to a key. Is there some way to do that? write a triggers which do that. depesz -- http://www.depesz.com/ - nowy, lepszy depesz ---(en

[GENERAL] deleting a foreign key that has no references

2007-03-19 Thread Glen W. Mabey
Hello, I'm using 8.1.8, and I have a situation where a record in one table is only meaningful when it is referenced via foreign key by one or more records in any one of several tables. So, really what I want is when one of the referring records is deleted, to have a trigger check to see if it was