Re: must I create the function check_primary_key ?

Поиск
Список
Период
Сортировка
Искать
От
Peter J. Schoenster
Тема
Re: must I create the function check_primary_key ?
Дата
Msg-id
3AE7F163.15642.11DD19@localhost
Ответ на
Список
Дерево обсуждения
must I create the function check_primary_key ? "Peter J. Schoenster" <borg@errorcode.com>
Re: must I create the function check_primary_key ? Stephan Szabo <sszabo@megazone23.bigpanda.com>
Re: must I create the function check_primary_key ? "Peter J. Schoenster" <peter@schoenster.com>
> 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  
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

В списке pgsql-sql по дате отправления
От: Vivek Khera
Дата:
Сообщение: Re: MySql 'REPLACE'
От: Hans-Jürgen Schönig
Дата:
FAQ