postgresql - Triger update function when column updates in Postgres -
i have users table columns status_id (int), additional_status(int) , status_changed(date).
i want autoupdate status_changed field every time when status_id or additional_status changes.
here have now:
create or replace function update_status_changed() returns trigger $$ begin new.status_changed := current_timestamp; return new; end $$ language plpgsql; create trigger set_update_status_changed after insert or update of status_id, additional_status on users each row execute procedure update_status_changed();
i'm not sure if syntax correct. when change status_id phppgadmin - status_changed stays null. i'm missing?, pls.
Comments
Post a Comment