开发者

In postgresql trigger function ------- How can I use NEW variable as an array?

We can use NEW.columnname and we get it's value.

Can I use NEW variable as array to get it's values? like NEW[1] or NEW.1 ...Or if I pass column names in one text array to trigger function argument then can I use NEW.$1 to get 1st c开发者_JAVA百科olumn value?

I have to do it only with language plpgsql


You can convert a row / rows to and from array(s), as described here.


I've suggested a dup question, since it's really the same underlying issue.


I'd be quite enthusiastic to be shown wrong (I occasionally need this myself too), but best I'm aware, referring column names using variables is one of those cases where you actually need to use PL/C triggers rather than PL/PgSQL triggers. You'll find examples of such triggers in contrib/spi and on PGXN.

Alternatively, write a function that writes your trigger using execute statements.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜