From: Peter J. Schoenster <peter@schoenster.com>
To: pgsql-sql@postgresql.org
Subject: Re: must I create the function check_primary_key ?
Date: Thu, 26 Apr 2001 09:58:59 -0600
Message-ID: <3AE7F163.15642.11DD19@localhost> (raw)
In-Reply-To: <Pine.BSF.4.21.0104252125150.17674-100000@megazone23.bigpanda.com>
References: <3AE7463E.27747.CD77E8D@localhost>
> On Wed, 25 Apr 2001, Peter J. Schoenster wrote:
>
> > I want to use this referential integrity etc. that I've never used
..snip..
> > CREATE TRIGGER employer_id_exists
> > BEFORE INSERT OR UPDATE ON company_profile FOR EACH
> > ROW
> > EXECUTE PROCEDURE check_primary_key('employer_id',
> > 'employer_profile', 'employer_id');
Stephan Szabo <sszabo@megazone23.bigpanda.com>
enlightened me as such:
> You probably just want to use a REFERENCES constraint
> employer_id int4 REFERENCES employer_profile(employer_id)
>
> You'll need to have a primary key or unique constraint
> on employer_profile(employer_id). The references constraint
> will also prevent you from deleting a employer_id
> row that is being referenced.
Banging my head on the table ... yes ... I never set the constraint
on employer_id in employer_profile. I should have been more
patient in reading the error message returned by psql.
Thanks for the help. Your suggestion worked as expected.
Peter
All idioms must be learned.
Good idioms only need to be learned once.
--Alan Cooper
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: peter@schoenster.com
Subject: Re: must I create the function check_primary_key ?
In-Reply-To: <3AE7F163.15642.11DD19@localhost>
References: <3AE7463E.27747.CD77E8D@localhost> <3AE7F163.15642.11DD19@localhost>
* 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