Forum: Building VoltDB Applications

Post: Type error for parameter 0

Type error for parameter 0
chbussler
Apr 14, 2010
Hi,

I got this runtime error. I am probably staring at the code for too long now, but I am sure that I pass an integer to an integer parameter. Any idea what this could be? If need be I can isolate out the code, of course.

[java] ===============================================================================
[java] VOLTDB ERROR: PROCEDURE ProcUpdate TYPE ERROR FOR PARAMETER 0: tryToMakeCompatible: Unable to match parameters:java.lang.Integer to provided java.lang.Integer
[java] ===============================================================================

Thanks,
Christoph
just when I pressed the save button ...
chbussler
Apr 14, 2010
... it occurred to me to check my other procedures. Turns out, when I change the procedure parameter from Integer to long, then it works. So I am passing an Integer from the client to a long parameter in the run method.

When the parameter in the stored procedure is an Integer, too, then the error message shows up, but at runtime, not compile time. Not sure if this is the intended behavior?

Thanks,
Christoph
re: TYPE ERROR FOR PARAMETER 0
tcallaghan
Apr 14, 2010
... it occurred to me to check my other procedures. Turns out, when I change the procedure parameter from Integer to long, then it works. So I am passing an Integer from the client to a long parameter in the run method.

When the parameter in the stored procedure is an Integer, too, then the error message shows up, but at runtime, not compile time. Not sure if this is the intended behavior?

Thanks,
Christoph


Christoph,
Its best to pass primitive types (int, long) rather than their Object representations (Integer, Long). I also try and match my parameters to the exact integer type of my datamodel, as in:

Java Type VoltDB Column Type
byte tinyint
short smallint
int integer
long bigint


Doing so will ensure the smallest possible size of the serialized stored procedure invocations across the network.

VoltDB will allow you to pass parameters to SQL (your "?" parameters in SQLStmt in your stored procedures) as long for all integer types, but I don't think that is good programming practice.

-Tim
Big Exclamation Mark
henning
Apr 16, 2010
Christoph,
Its best to pass primitive types (int, long) rather than their Object representations (Integer, Long). I also try and match my parameters to the exact integer type of my datamodel, as in:..

-Tim


Since I ran into the exact same irritation, a big box with a hint to this pitfall in the docs seems in order. In two places even, for me.

If I should have overlooked it, well, Christoph seems to have done that too, and it would simply ask for a more prominent warning.

The error message might be the right place for a hint as well.

I think at this stage, everyone would accept if the hint came even if it was superfluous. To make things easier, you could just always add it to this type of error message, without inspection of the actual types. "See https://community.voltdb.com/comment/reply/74" for example. Or sth. like "use int for Integer, ... see 'Native Types in SP Signatures' Manual."

Thanks,
Henning
Hi Henning, Christoph, Adding
ajgent
Apr 16, 2010
Since I ran into the exact same irritation, a big box with a hint to this pitfall in the docs seems in order. In two places even, for me...

Henning


Hi Henning, Christoph,

Adding a warning to the documentation concerning what datatypes to use when passing parameters to the stored procedures sounds like a good idea. Thanks for the suggestion.

--Andrew
Inserting a Integer column with NULL stores it as -2147483648
shetty_ritesh
Apr 20, 2010
hi,

I have a column in the table which is of type Integer. When i insert data into this table i add the value as NULL. This results in storing the value as -2147483648 instead of NULL.
Is this by design or some bug ?

Regards
Ritesh
By design
aweisberg
Apr 20, 2010
hi,

I have a column in the table which is of type Integer. When i insert data into this table i add the value as NULL. This results in storing the value as -2147483648 instead of NULL.
Is this by design or some bug ?

Regards
Ritesh


Hi Shetty,

Volt uses the minimum representable value to represent NULL for the primitive types TINYINT, SMALLINT, INTEGER, BIGINT, DOUBLE. You need to call VoltTableRow.wasNull() after retrieving a column value if there is a possibility that the column might contain a NULL value. This mimics the interface of JDBC.

-Ariel
We've identified this as a bug
jhugg
May 13, 2010
This is a bug. VoltDB 0.9 and previous versions fail when you try to call procedures with boxed value types; i.e. "int" is valid but "Integer" is not. It still lets you compile these procedures. For 1.0, we plan to fail compilation when we find a boxed type and give the user a clear error. See issue ENG-540.

In the meantime, use un-boxed types as procedure params and you should be all set.
We plan to enable boxed types in a post 1.0 version. See issue ENG-539.

Thanks for the feedback.