Re: Updating
От | Daniel Verite |
---|---|
Тема | Re: Updating |
Дата | |
Msg-id | 4e715e28-cdbe-4302-b644-5c14180ff5cb@mm обсуждение исходный текст |
Ответ на | Re: Updating (Adrian Klaver <aklaver@comcast.net>) |
Ответы |
Re: Updating
|
Список | pgsql-general |
Adrian Klaver wrote: > CREATE FUNCTION foo() RETURNS trigger AS > $Body$ > BEGIN > IF NEW.colname != OLD.colname THEN > ..."Do something"..; > RETURN whatever; > ELSE > RETURN NEW: > END IF; > END; > $Body$ LANGUAGE plpgsql; Beware that the "Do something" code path will not be taken when the column goes from NULL to non-NULL or non-NULL to NULL. In the general case where the column is nullable, better use "IS DISTINCT FROM" instead of inequality: IF NEW.colname IS DISTINCT FROM OLD.colname Best regards, -- Daniel PostgreSQL-powered mail user agent and storage: http://www.manitou-mail.org
В списке pgsql-general по дате отправления: