CallableStatement: java.sql.Types=12 however type java.sql.Types=1111 was registered

From: Jerome Colombie <jcolombie(at)gmx(dot)ch>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: CallableStatement: java.sql.Types=12 however type java.sql.Types=1111 was registered
Date: 2004-12-21 21:19:11
Message-ID: 41C8934F.9060403@gmx.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi

I get the following error:

org.postgresql.util.PSQLException: A CallableStatement function was
executed and the return was of type java.sql.Types=12 however type
java.sql.Types=1111 was registered.

when running the following code:

conn.setAutoCommit(false);
CallableStatement stmt = conn.prepareCall("{ ? = call
myfunction1() }");
stmt.registerOutParameter(1, Types.OTHER);
stmt.execute();
ResultSet rs = (ResultSet) stmt.getObject(1);
while (rs.next()) {
result = result + rs.getString(1);
result = result + rs.getDouble(2);
}

create type b_line as (account_text varchar(255), amount numeric);

CREATE OR REPLACE FUNCTION myfunction1()
RETURNS setof b_line AS
$BODY$DECLARE
tmp1 numeric;
account RECORD;
r b_line%rowtype;
BEGIN
tmp1 = 0.00;
FOR i IN 30..39 LOOP
FOR account IN SELECT id, account_id, name, type, amount_cred FROM
bo.obj_ledger WHERE account_id like (i || '__') ORDER BY id LOOP
IF account.type = 'P' THEN
tmp1 = tmp1 + account.amount_cred;
ELSE
tmp1 = tmp1 - account.amount_cred;
END IF;
END LOOP;
END LOOP;
r.account_text = 'Line1:';
r.amount = tmp1;
return next r;
RETURN;
END;$BODY$
LANGUAGE 'plpgsql' VOLATILE;

I'm using the following versions:
pg80b1.308.jdbc3.jar
PostgreSQL 8.0.0rc1 on i686-pc-mingw32, compiled by GCC gcc.exe (GCC)
3.3.1 (mingw special 20030804-1)

Thanks for your help.

Regards,
Jerome

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2004-12-21 21:35:25 Re: CallableStatement: java.sql.Types=12 however type
Previous Message Kris Jurka 2004-12-21 19:57:58 Re: currval bug??