8

I'm going to create a trigger before/after update on specific columns of a table in postgresql but i can't do that.

i can bind trigger to fire after update a specific column of a specific table but i can't do that for more than one column. i want to know is it possible?

i don't want to solve it using writing IF(UPDATE(column series)) in my trigger function

--i tried below code but it give me error near ','

    create trigger save_information after update of table_name on day, month
    for each row
               execute procedure save_function();

-- but below code (by mentioning just a single column) works fine:

    create trigger save_information after update of table_name on day
    for each row
               execute procedure save_function();

i don't want to change my save_function to solve it or use 'IF(update(column series)' statement. excuse me for my weak writing.

2
  • Can you share the exact error message please? Commented Apr 3, 2019 at 6:36
  • the exact error is: ERROR: syntax error at or near "," LINE 28: ...formation after update of table_name on day , month... ^ SQL state: 42601 Character: 1061 Commented Apr 3, 2019 at 9:36

1 Answer 1

12

As documented in the manual the column name(s) are listed after the OF keyword.

So it should be:

create trigger save_information 
     after update of day, month
     on table_name 
for each row execute procedure save_function();
Sign up to request clarification or add additional context in comments.

1 Comment

thank you very very much. it solved the problem. excuse me if it was so simple:|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.