Trigger with dynamic field name
问题 I have a problem on creating PostgreSQL (9.3) trigger on update table. I want set new values in the loop as EXECUTE 'NEW.'|| fieldName || ':=''some prepend data'' || NEW.' || fieldName || ';'; where fieldName is set dynamically. But this string raise error ERROR: syntax error at or near "NEW" How do I go about achieving that? 回答1: You can implement that rather conveniently with the hstore operator #= : Make sure the additional module is installed properly ( once per database), in a schema