pgjdbc-ng icon indicating copy to clipboard operation
pgjdbc-ng copied to clipboard

Postgres stored procedures via CallableStatement

Open aleks-oracle opened this issue 6 years ago • 2 comments

Hello.

Since Postrges JBDC driver cannot work with stored procedures (only functions) via CallableStatement, I tried pgjdbc-ng one.

During the execution of the following code I get the exception:

com.impossibl.postgres.jdbc.PGSQLSimpleException: get_organization(bigint, character varying, numeric, integer, jsonb, character varying) is a procedure

`

 CallableStatement cs = con.prepareCall("{CALL get_organization(?,?,?,?,?::jsonb,?)}")) {
  cs.setObject(1, id, Types.BIGINT);
  cs.setObject(2, kbm, Types.VARCHAR);
  cs.setBigDecimal(3, BigDecimal.ONE);
  cs.setInt(4, 0);
  cs.setObject(5, "");
  cs.setString(6, "");
  cs.registerOutParameter(3, Types.NUMERIC);
  cs.registerOutParameter(4, Types.INTEGER);
  cs.registerOutParameter(5, Types.OTHER);
  cs.registerOutParameter(6, Types.VARCHAR);
  ResultSet rs = cs.executeQuery();

`

What does it mean? That this driver cannot work with postgres stored procedures either? I found zero information related to this. FYI: The procedure has 2 IN parameters and 4 INOUT parameters.

aleks-oracle avatar Oct 27 '19 11:10 aleks-oracle

The better question is why do you want to use a stored procedure ? They kinda suck at the moment

davecramer avatar Nov 03 '19 11:11 davecramer

I am a test automation engineer, and have to call stored procedures since our developers use them in application. I cannot forbid our devs from using them.

The question is still actual.

aleks-oracle avatar Nov 05 '19 07:11 aleks-oracle