X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6AB73D1B4EB for ; Thu, 25 Sep 2003 19:17:33 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 48057-10 for ; Thu, 25 Sep 2003 16:17:02 -0300 (ADT) Received: from lerami.lerctr.org (lerami.lerctr.org [207.158.72.11]) by svr1.postgresql.org (Postfix) with ESMTP id C33F5D1B536 for ; Thu, 25 Sep 2003 16:17:00 -0300 (ADT) Received: from lerlaptop-red.iadfw.net (lerlaptop-red.iadfw.net [207.136.3.72]) (authenticated bits=0) by lerami.lerctr.org (8.12.10/8.12.10/20030923) with ESMTP id h8PJGsQa011469; Thu, 25 Sep 2003 14:16:54 -0500 (CDT) Date: Thu, 25 Sep 2003 14:16:53 -0500 From: Larry Rosenman To: Richard Huxton , pgsql-sql@postgresql.org Subject: Re: weird(to me) request Message-ID: <324780000.1064517413@lerlaptop-red.iadfw.net> In-Reply-To: <200309252009.35449.dev@archonet.com> References: <294260000.1064515888@lerlaptop-red.iadfw.net> <200309252009.35449.dev@archonet.com> X-Mailer: Mulberry/3.1.0b7 (Linux/x86) X-PGP-Info: All other keys are old/dead. X-PGP-Key: 0x3c49bdd6 X-PGP-Fingerprint: D0D1 3C11 F42F 6B29 FA67 6BF3 AD13 4685 3C49 BDD6 MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="==========7674B1DA2139D171B282==========" X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/315 X-Sequence-Number: 15293 --==========7674B1DA2139D171B282========== Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline --On Thursday, September 25, 2003 20:09:35 +0100 Richard Huxton=20 wrote: > On Thursday 25 September 2003 19:51, Larry Rosenman wrote: >> I have the following rows (in addition to others): >> >> acct_num text, >> master_acct_num text, >> >> >> These are in the same table. >> >> What I want to enforce is that if the master_acct_num field is NOT NULL >> (it can be NULL, and >> that's fine), that the value appears in some row as acct_num. acct_num >> has a unique index on it, so that's fine. >> >> I'm not sure how to do this.... > > ALTER TABLE my_table ADD CONSTRAINT my_self_fk FOREIGN KEY > (master_acct_num) REFERENCES my_table (acct_num); > > It's really just a foreign-key to yourself I wasn't sure I could do that. Thanks! LER --=20 Larry Rosenman http://www.lerctr.org/~ler Phone: +1 972-414-9812 E-Mail: ler@lerctr.org US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749 --==========7674B1DA2139D171B282========== Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQE/cz8mrRNGhTxJvdYRAuEfAJ9YtGpucHc8LbVtyuhxl9H7uxi/vgCfSw1c YOycR/BekUFab6ojZO1r3Kg= =OUMf -----END PGP SIGNATURE----- --==========7674B1DA2139D171B282==========--