Re: Functions and Triggers
От | Jan Wieck |
---|---|
Тема | Re: Functions and Triggers |
Дата | |
Msg-id | 200103270959.EAA26759@jupiter.jw.home обсуждение исходный текст |
Ответ на | Re: Functions and Triggers (Cedar Cox <cedarc@visionforisrael.com>) |
Список | pgsql-sql |
Cedar Cox wrote: > > CREATE FUNCTION lastupdated() RETURNS opaque AS ' > begin > new.last_updated := CURRENT_TIMESTAMP; > return new; > end; > ' LANGUAGE 'plpgsql'; > > CREATE TRIGGER trigname BEFORE INSERT OR UPDATE on tblname > FOR EACH ROW EXECUTE PROCEDURE lastupdated(); > > Note: you could use now() instead of CURRENT_TIMESTAMP > > Note2: on a BEFORE trigger you must return new or old. If you return null > the statement will be aborted. (?) If you return NULL from a BEFORE trigger the action on that particular row will be silently suppressed. Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com # _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
В списке pgsql-sql по дате отправления: