X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 13212D1B182 for ; Mon, 28 Jun 2004 23:26:09 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 55748-10 for ; Tue, 29 Jun 2004 02:26:04 +0000 (GMT) Received: from sharp.noc24x7.com (unknown [69.56.128.138]) by svr1.postgresql.org (Postfix) with ESMTP id D8E31D1B18E for ; Mon, 28 Jun 2004 23:25:53 -0300 (ADT) Received: from [61.1.218.152] (helo=thenilgiris.com) by sharp.noc24x7.com with asmtp (Exim 4.34) id 1Bf8Jn-00015U-9w for pgsql-sql@postgresql.org; Tue, 29 Jun 2004 07:55:56 +0530 Received: from localhost (localhost [[UNIX: localhost]]) by thenilgiris.com (8.11.2/8.11.2) id i5T0mgJ03404 for pgsql-sql@postgresql.org; Tue, 29 Jun 2004 06:18:42 +0530 Content-Type: text/plain; charset="iso-8859-1" From: Kenneth Gonsalves To: Subject: finding if a foreign key is in use Date: Tue, 29 Jun 2004 06:18:41 +0530 X-Mailer: KMail [version 1.2] MIME-Version: 1.0 Message-Id: <0406290618410W.02481@thenilgiris.com> Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - sharp.noc24x7.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - thenilgiris.com X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_DSBL X-Spam-Level: * X-Archive-Number: 200406/285 X-Sequence-Number: 18230 in my app i have a table where the id serves as a foreign key for one or more other tables. if i want to delete a row in the table, i currently search the other tables where this table is referenced to see if the row is in use - and then, if not in use, permit deletion. Now if i want the delete button in my app to be disabled whenever a row that is in use is selected, searching the database every time would dramatically slow down the app. is there some sql query that will immediatly give an answer as to whether the row is in use or not? -- regards kg http://www.onlineindianhotels.net - hotel bookings reservations in over 4600 hotels in India http://www.ootygolfclub.org