I have table like this
id | col1 | col2
I need write trigger so: after inserting or updating column col1
, I need insert (update) same value in column col2
This is my trigger function:
CREATE FUNCTION upd () RETURNS TRIGGER AS '
BEGIN
UPDATE mytable SET
col2 = col1;
RETURN NULL;
END;
'
LANGUAGE plpgsql;
and this is self trigger:
CREATE TRIGGER upd_trigger
AFTER INSERT OR UPDATE ON mytable
FOR EACH ROW
EXECUTE PROCEDURE upd()
This not works because happening cycloning at UPDATE
event, right?
What is right syntax for do this?