ices-eg / wg_WGEEL

Joint EIFAAC/ICES/GFCM Working Group on Eels
http://ices.dk/community/groups/Pages/WGEEL.aspx
5 stars 12 forks source link

trigger not fired for eel_last_update when correcting on the database #169

Closed cedricbriandgithub closed 2 years ago

cedricbriandgithub commented 3 years ago

CREATE TRIGGER update_eel_time BEFORE INSERT OR UPDATE ON datawg.t_eelstock_eel FOR EACH ROW EXECUTE PROCEDURE datawg.update_eel_last_update();

CREATE OR REPLACE FUNCTION datawg.update_eel_last_update() RETURNS trigger LANGUAGE plpgsql AS $function$ BEGIN NEW.eel_datelastupdate = now()::date; RETURN NEW; END; $function$ ;

elfunesto commented 2 years ago

i think it should be an "after" trigger rather than a "before" trigger

elfunesto commented 2 years ago

made some tests with both insert and update and it is working