Constraint Question

Поиск
Список
Период
Сортировка
От Kai Hessing
Тема Constraint Question
Дата
Msg-id 47tki5Fh5nsuU1@individual.net
обсуждение исходный текст
Ответы Re: Constraint Question  (Bruno Wolff III <bruno@wolff.to>)
Список pgsql-general
Hi Folks,

I'm not perfekt in SQL so I'm not really sure, how this can be done.

I have a master table stud containing (amongs others) two rows called
'sid' and 'status'. Now I have different tables using constraints to
reference this table. For example I have one table called phon with the
rows 'phonid', 'sid' and 'status'. 'sid' is currently the Foreign Key
and the Entry in Phone is updated oder deleted, when the sid in the
master table is. So far so good.

The 'status'-row can contain either 1 or -1 and -4. And now I would like
to implement the action that if the the status field in the master table
for a special sid is changed, all status-fields in phon for entries
which referencing this sid are also changed.

Can this be done somehow with a foreign key? If it can, how?

Else I think it could be done about a trigger that is set in the
mastertable for setup. The problem is, the Trigger must be updated
everytime a new table is added, that references the master table. Or is
it possible to write a Trigger for the phon-table that checks the status
field from stud everytime it is updated, so I can implement additional
functionality (somewhat like ' if (phon.status=1 or phon.status=-1) and
(stud.status is updated) then phon.status=stud.status ' )?

Thanks and *greets*
Kai...

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: pg_dumpall: permission denied for relation pg_shadow
Следующее
От: "Ing. Claudio Roberto Seu"
Дата:
Сообщение: pregunta de principiante