Postgres Function NULL value for row that references NEW

◇◆丶佛笑我妖孽 提交于 2019-11-29 17:51:57

I'll have to guess, because you cunningly kept the function definition a secret. (Irony intended.)

Most probably you are running into a naming conflict. Parameter names (IN and OUT parameters) are visible in the function body (almost) anywhere and take precedence over unqualified column names. Did you declare col1 as variable in the function?

To avoid the conflict, table-qualify the column name:

SELECT b.col1 FROM tableb b WHERE b.aID = NEW.ID;

This is good practice in any case.

It is also good practice to prefix variable names, so they wouldn't normally conflict with table columns. Like: _col1.

Post the complete function definition if that didn't solve the problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!