Out parameters for functions. - Mailing list pgsql-jdbc

From Robert Zenz
Subject Out parameters for functions.
Date
Msg-id 5BA2606B.60607@sibvisions.com
Whole thread Raw
Responses Re: Out parameters for functions.  (Dave Cramer <pg@fastcrypt.com>)
Re: Out parameters for functions.  (Mark Rotteveel <mark@lawinegevaar.nl>)
List pgsql-jdbc
Hello everybody.

We've recently had to use functions which used OUT parameters and we are a
little bit confused regarding the handling of such. In other JDBC drivers one
does simply register the OUT parameter at the appropriate position in the
parameter list. However, with the PostgreSQL JDBC driver we had to skip the
registration of the OUT parameter altogether, the return value for the OUT
parameter is then returned *after* all other parameters.

Example, there is function which does accept three parameters:

 1. IN numeric
 2. OUT varchar
 3. INOUT timezone

When calling this function we have to do the following:

    CallableStatement statement = connection.prepareCall("{ ? = call test(?, ?) }");
    statement.registerOutParameter(1, Types.NUMERIC); // Return value.
    statement.setObject(2, value); // IN numeric
    statement.setObject(3, value); // INOUT timezone

    statement.execute();

    statement.getObject(4); // OUT varchar

This is a little bit confusing at first, is that intended to behave as such?

pgsql-jdbc by date:

Previous
From: zloster
Date:
Subject: Re: ssl connection issues
Next
From: Roger Pack
Date:
Subject: isValid(5) doesn't come back