Re: Update on tables when the row doesn't change
От | Dawid Kuroczko |
---|---|
Тема | Re: Update on tables when the row doesn't change |
Дата | |
Msg-id | 758d5e7f05052503371154ef65@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Update on tables when the row doesn't change (Sebastian Böck <sebastianboeck@freenet.de>) |
Ответы |
Re: Update on tables when the row doesn't change
|
Список | pgsql-general |
On 5/25/05, Sebastian Böck <sebastianboeck@freenet.de> wrote: > >>CREATE OR REPLACE FUNCTION upd (view_test) RETURNS VOID AS $$ > >> DECLARE > >> NEW ALIAS FOR $1; > >> BEGIN > >> RAISE NOTICE 'UPDATE'; > >> UPDATE test SET test = NEW.test WHERE id = OLD.id; > >> UPDATE join1 SET text1 = NEW.text1 WHERE id = OLD.id; > >> UPDATE join2 SET text2 = NEW.text2 WHERE id = OLD.id; > >> UPDATE join3 SET text3 = NEW.text3 WHERE id = OLD.id; > >> RETURN; > >> END; > >>$$ LANGUAGE plpgsql; > > > > > > Control question, I didn't check it, but would it be enough to change from: > > UPDATE join1 SET text1 = NEW.text1 WHERE id = OLD.id; > > to: > > UPDATE join1 SET text1 = NEW.text1 WHERE id = OLD.id AND text1 <> NEW.text1? > > > > ... I may be wrong. :) > > Yes, thats more elegant then my other (4th) solution. > Was late yesterday evening ;) Be wary of the NULL values though. :) Either don't use them, add something like 'AND (text1 <> NEW.text1 OR text1 IS NULL OR NEW.text1 IS NULL)' or something more complicated. :) Regards, Dawid
В списке pgsql-general по дате отправления: