db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel John Debrunner <...@debrunners.com>
Subject Re: How to return null param from a stored procedure?
Date Sun, 03 Oct 2004 02:00:23 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jeremy Boynes wrote:

> I have a stored procedure where I want to return a null value from one
> its parameters - something like:
>
>     public static void Int_Proc2(Integer[] param) {
>         param[0] = null;
>     }
>
> I am declaring this to Derby as:
>   CREATE PROCEDURE Int_Proc2(OUT param INTEGER)
>   PARAMETER STYLE JAVA
>   LANGUAGE JAVA
>   READS SQL DATA
>   EXTERNAL NAME 'test.jdbc.CallableStatementTest.Int_Proc2'
>
> but a prepareCall("{call Int_Proc2(?)}");
> throws a 42X50 SQLException (no method found ...)
>
> Using a primitive int works fine but obviously I can't return null that
> way. How should I be doing this?

Derby always maps SMALLINT, INTEGER, REAL, DOUBLE, BIGINT SQL types to
Java primitives (short, int, float, double, long) for procedure and
functions. Thus passing SQL NULLS or returning them for OUT parameters
is not supported.

CHAR, VARCHAR, DECIMAL map to Java object types (String, String,
BigDecimal) and thus can be used to pass & return NULL values.

Dan.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFBX103Iv0S4qsbfuQRArLfAJ9iePLyhMUqXVDYBLjmW9JQKvUJ/ACgr6rT
DfqXKq0uynDzCQDvjBe5ldg=
=FCrn
-----END PGP SIGNATURE-----


Mime
View raw message