PostgreSQL function does not exist

允我心安 提交于 2019-12-11 10:24:07

问题


I'm using the SQL query which uses a custom written function similar to this

CREATE OR REPLACE FUNCTION per_cont(myarray integer[], percentile real)

This works perfectly in the pgAdmin tool, but when I use this query in my java application it gives me an error:

function per_cont(integer[], real) does not exist

I'm using JDBI library to interact with the database. Why doesn't it find the function when running it from a java application? How can I fix it?


回答1:


The error message doesn't make sense at all for the CREATE OR REPLACE FUNCTION command you show. Assuming you are actually calling the function in a DML statement like

SELECT per_cont('{1,2,3}', 1);

Obviously you have to be using the same database, but you say that has been established.

Your search_path also has to match. Since you are not providing a schema explicitly, the function is created in the "current" schema when created. The same schema has to show up in the search_path of the other session or the function is not visible.

Detailed instructions in the linked answer:

  • How does the search_path influence identifier resolution and the "current schema"


来源:https://stackoverflow.com/questions/27497775/postgresql-function-does-not-exist

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