"out" parameters in CallableStatements

Поиск
Список
Период
Сортировка
Искать

"out" parameters in CallableStatements

От:
"David Parker" <dparker@tazznetworks.com>
Дата:
Hi. I need to provide a stored procedure interface to my postgres
database that conforms as much as possible to an existing Oracle stored
procedure interface in a product with which we are integrating. These
are called via JDBC. The Oracle interface has OUT parameters, which are
not supported by postgres, so I assume my stored procedures just need to
return this value (luckily, they only seem to have one OUT parameter per
procedure, which they use for a result). 

I'm not sure how to handle this at the JDBC level. The example in the
postgres documentation (page 417 in the 7.4 doc) gives:

CallableStatement upperProc = con.prepareCall("{ ? = call upper( ? )
}");
upperProc.registerOutParameter(1, Types.VARCHAR);
upperProc.setString(2, "lowercase to uppercase");
upperProc.execute();
String upperCased = upperProc.getString(1);
upperProc.close();

Is the JDBC driver doing something special to support the
registerOutParameter call? Assuming that it is using this to map the
return value of the stored procedure, does it check that only one OUT
parameter is registered, or limit it to parameter 1?

TIA for any info.

-  DAP
====================================================== 
David Parker    Tazz Networks    (401) 709-5130
 

Re: "out" parameters in CallableStatements

От:
Kris Jurka <books@ejurka.com>
Дата:


On Thu, 23 Sep 2004, David Parker wrote:

> Is the JDBC driver doing something special to support the
> registerOutParameter call? Assuming that it is using this to map the
> return value of the stored procedure, does it check that only one OUT
> parameter is registered, or limit it to parameter 1?
> 

It is currently limited to the first parameter.  Dave Cramer has produced 
a patch to allow full in/out parameter support, but this requires some 
complicated modifications to the stored procedure code.  Since no one 
has really requested this functionality and people are discussing adding 
real in/out backend support for 8.1 we are currently waiting to see how 
the real backend support works out before introducing this temporary hack 
that will undoubtedly cause some backward compatibility problems.

http://archives.postgresql.org/pgsql-jdbc/2004-09/msg00004.php

Kris Jurka
FAQ