From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-jdbc@postgresql.org
Subject: CallableStatement.getParameterMetaData() throws exception for valid {call ...} statement
Date: Sat, 30 May 2015 10:21:52 +0200
Message-ID: <mkbrv5$vfc$1@ger.gmane.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
Hello,
I just noticed the following:
Using this sample function from the manual:
CREATE FUNCTION sum_n_product(x int, y int, OUT sum int, OUT prod int) AS $$
BEGIN
sum := x + y;
prod := x * y;
END;
$$ LANGUAGE plpgsql;
When calling this through JDBC, the following works without problems:
cstmt = connection.prepareCall("{call sum_n_product(?,?,?,?)}");
cstmt.registerOutParameter(3, Types.INTEGER);
cstmt.registerOutParameter(4, Types.INTEGER);
cstmt.setInt(1, 2);
cstmt.setInt(2, 5);
cstmt.execute();
int x1 = cstmt.getInt(3);
int x2 = cstmt.getInt(4);
System.out.println("x1: " + x1);
System.out.println("x2: " + x2);
However when calling
ParameterMetaData meta = cstmt.getParameterMetaData();
after prepareCall() the following exception is thrown:
org.postgresql.util.PSQLException: ERROR: function sum_n_product(unknown, unknown, unknown, unknown) does not exist
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Position: 15
Casting everything to integer ( "{call sum_n_product(?::int,?::int,?::int,?::int)}" ) produces the same error (except that the parameter list shows integer in the exception message).
This looks like a bug to me. Why should getParameterMetaData() throw an exception if the call is valid and working?
Driver version is 9.4-1200
Postgres version is 9.4.2
Java version is 1.7.0_55
Regards
Thomas
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
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: spam_eater@gmx.net
Subject: Re: CallableStatement.getParameterMetaData() throws exception for valid {call ...} statement
In-Reply-To: <mkbrv5$vfc$1@ger.gmane.org>
References: <mkbrv5$vfc$1@ger.gmane.org>
* 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