Re: Is it possible to redirect an update/insert/delete to a different table?

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: Is it possible to redirect an update/insert/delete to a different table?
Дата
Msg-id 200511201535.57300.aklaver@comcast.net
обсуждение исходный текст
Ответ на Re: Is it possible to redirect an update/insert/delete to a different table?  (Andy Ballingall <andy@areyoulocal.co.uk>)
Список pgsql-sql
On Sunday 20 November 2005 09:15 am, Andy Ballingall wrote:
It works because of the way updates are done. When you do an update two 
versions of the row exist. The OLD version is the row as it existed before 
you updated. The NEW version contains the entire version with the update 
changes. The key thing to remember is the the NEW version contains both those 
fields that have changed as well as those that have not. So the UPDATE rule 
just passes along all the fields named in it regardless of whether they 
changed or not. It would be a good idea to read the following section of the 
manual (http://www.postgresql.org/docs/8.0/interactive/rules.html) as it 
explains when the rule picks up the values in the fields. This differs 
according to the type of rule.
> >Try it. [snipped example]
>
> Ah. Basically, you set up the rule to assign every column, and if the
> update doesn't redefine some columns, then it still works. I didn't
> understand that you could get the rule to work generically like this.
>
> I'll presume that the rule will need amending if the table column
> definition later changes. (E.g. if I add 'stalk_length' to my apples and
> pears tables)...
>
> Thanks very much for your help.
>
> Andy
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings

-- 
Adrian Klaver    
aklaver@comcast.net


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

Предыдущее
От: "Grigory O. Ptashko"
Дата:
Сообщение: Please help to wite the constraint.
Следующее
От: Hélder M. Vieira
Дата:
Сообщение: max() unexpected type conversion