From: Richard Huxton <dev@archonet.com>
To: Larry Rosenman <ler@lerctr.org>
To: pgsql-sql@postgresql.org
Subject: Re: weird(to me) request
Date: Thu, 25 Sep 2003 20:09:35 +0100
Message-ID: <200309252009.35449.dev@archonet.com> (raw)
In-Reply-To: <294260000.1064515888@lerlaptop-red.iadfw.net>
References: <294260000.1064515888@lerlaptop-red.iadfw.net>
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
--
Richard Huxton
Archonet Ltd
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dev@archonet.com, ler@lerctr.org
Subject: Re: weird(to me) request
In-Reply-To: <200309252009.35449.dev@archonet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox