From: Michael Schwipps <msc.listen@online.de>
To: pgsql-jdbc@postgresql.org
Subject: float4 or real in function parameter -> PSQLException: ERROR function in_test4(double precision) does not exist
Date: Wed, 5 Aug 2009 12:35:47 +0200
Message-ID: <20090805103547.GA19462@codersinn.mschwipps.de> (raw)
Hi,
We use database functions in our application.
Today I want to use a float4/real Parameter for the first time. You can
see a sample in in_test4.
Float8/double-parameters run fine.
The test.sql creates a small test database.
The Float4Test.java contains the code sample, which throws the following
exception.
| Hint: No function matches the given name and argument types. You
| might need to add explicit type casts.
| Position: 8
| at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2062)
| at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1795)
| at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
| at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
| at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
| at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:360)
| at Float4Test.main(Float4Test.java:24)
If I call
| Select in_test4(0.4) ;
in psql, everything runs fine.
Is it a bug in the JDBC-driver?
I use postgres 8.4.0 and driver postgresql-8.4-701.jdbc4.jar.
Ciao
Michael
Attachments:Float4Test.java (text/plain, 914B) download
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class Float4Test {
public static void main(String[] args) {
try {
Class.forName("org.postgresql.Driver");
Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost/test",
"postgres", "postgres");
conn.setAutoCommit(false);
PreparedStatement st = conn.prepareStatement("Select in_test8(?);");
st.setFloat(1, 0.8f);
st.execute();
st.close();
conn.commit();
st = conn.prepareStatement("Select in_test4(?);");
st.setFloat(1, 0.4f);
st.execute();
st.close();
conn.commit();
conn.close();
} catch(Exception e) {
e.printStackTrace();
}
}
}
test.sql (text/plain, 539B) download
create table float4test (id serial primary key, nr float4);
create language plpgsql;
CREATE OR REPLACE FUNCTION in_test4(pnr float4) RETURNS integer AS $$
DECLARE
datas RECORD;
BEGIN
Insert into float4test (nr) values (pnr) returning id into datas;
RETURN datas.id;
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION in_test8(pnr float8) RETURNS integer AS $$
DECLARE
datas RECORD;
BEGIN
Insert into float4test (nr) values (pnr) returning id into datas;
RETURN datas.id;
END;
$$ LANGUAGE plpgsql;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: msc.listen@online.de
Subject: Re: float4 or real in function parameter -> PSQLException: ERROR function in_test4(double precision) does not exist
In-Reply-To: <20090805103547.GA19462@codersinn.mschwipps.de>
References: <20090805103547.GA19462@codersinn.mschwipps.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox