Re: Complete instruction in a trigger
От | Tom Lane |
---|---|
Тема | Re: Complete instruction in a trigger |
Дата | |
Msg-id | 19794.1106838392@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: Complete instruction in a trigger (Wilton <wilton.wonrath@microwork.inf.br>) |
Список | pgsql-sql |
Wilton <wilton.wonrath@microwork.inf.br> writes: > I have a table "customers", then a user go there and change the customer > record, for example he changes the zip code column. Then I can know that > something changed into the "customer table", and send a full update of > that record through the web to the database that i want, but i need to > know what column had changed to send a update just for that column. But > i do not know in which column his has made that change. So, i need to > know the instruction to do this. Something like a specific update for > that column modified by the user. People ask for this often, and in every case I've seen, they would be wrong to depend on it if they had it. The reason is that the original SQL query is not sufficient information to tell which columns changed. Consider for example the possibility that the query was rewritten by a rule, or the new tuple was modified by another trigger that executed ahead of yours. The only correct way to determine which columns changed is to compare the OLD and NEW values of each column ... and you'd better do it in an AFTER trigger, not a BEFORE trigger, if you want to be certain that you are looking at the final result. regards, tom lane
В списке pgsql-sql по дате отправления: