From: Jerome Colombie <jcolombie@gmx.ch>
To: pgsql-jdbc@postgresql.org
Subject: CallableStatement: java.sql.Types=12 however type java.sql.Types=1111 was registered
Date: Tue, 21 Dec 2004 22:19:11 +0100
Message-ID: <41C8934F.9060403@gmx.ch> (raw)
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
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: jcolombie@gmx.ch
Subject: Re: CallableStatement: java.sql.Types=12 however type java.sql.Types=1111 was registered
In-Reply-To: <41C8934F.9060403@gmx.ch>
References: <41C8934F.9060403@gmx.ch>
* 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