From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | "Peter J(dot) Schoenster" <borg(at)errorcode(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: must I create the function check_primary_key ? |
Date: | 2001-04-26 04:28:00 |
Message-ID: | Pine.BSF.4.21.0104252125150.17674-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Wed, 25 Apr 2001, Peter J. Schoenster wrote:
> I want to use this referential integrity etc. that I've never used in
> mysql ... so I tried many things and looked here and there ... My
> example below produces this error:
>
> > CreateTrigger: function check_primary_key() does not exist
>
> Here is what I was trying to create:
>
> DROP TABLE company_profile;
>
> CREATE TABLE company_profile (
> employer_id int4,
> leadership text,
> company_description text,
> key_financial_statictics varchar (255),
> company_name varchar (255),
> url varchar (255),
> sec_fillings_url varchar (255),
> mission text,
> employees int4,
> type varchar (50),
> growth_rate varchar (50),
> culture text,
> year int4,
> PRIMARY KEY (employer_id)
> );
>
> 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');
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.
From | Date | Subject | |
---|---|---|---|
Next Message | Emils Klotins | 2001-04-26 10:54:19 | Regexps -- too complex? |
Previous Message | Peter J. Schoenster | 2001-04-26 03:48:46 | must I create the function check_primary_key ? |