1

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?

3
  • 1
    You're not connecting to the same database you think you are, most likely. Commented Dec 16, 2014 at 5:39
  • I also thought whether I'm making that mistake, but checked it several times. In JDBI do we have to import the postgresql function externally, or does this library automatically recognizes the functions? Commented Dec 16, 2014 at 5:45
  • How do you "use" the function exactly? Obviously, you must provide the command that triggered the error message. And be sure to provide the complete error message. And your version of Postgres (as always). Commented Dec 16, 2014 at 13:17

1 Answer 1

4

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:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.