PostgreSQL函数不存在 [英] PostgreSQL function does not exist

查看:2094
本文介绍了PostgreSQL函数不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SQL查询,该查询使用与此类似的自定义编写函数

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)

这在pgAdmin工具中完美地工作,但是当我在Java应用程序中使用此查询时,它给了我一个错误:

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

我正在使用JDBI库与数据库进行交互.从Java应用程序运行时为什么找不到函数?我该如何解决?

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?

推荐答案

对于您显示的CREATE OR REPLACE FUNCTION命令,错误消息完全没有意义.假设您实际上是在DML语句(如

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.

您的 search_path 也必须匹配.由于您没有显式提供架构,因此在创建函数时将在当前"架构中创建该函数.必须在另一个会话的search_path中显示相同的架构,否则该功能不可见.

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:

这篇关于PostgreSQL函数不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆