Forum: Building VoltDB Clients

Post: strange behaviour with float

strange behaviour with float
etr
May 8, 2012
I have a structure like this inside my db
CREATE TABLE price (
id INT NOT NULL,
currency_id INT NOT NULL,
label VARCHAR(45) NOT NULL,
value FLOAT NOT NULL,
PRIMARY KEY(id)
);

and a stored procedure having this signature:
public class PriceAdd extends VoltProcedure {

.....

public long run(int currencyId, String label, float value) throws VoltAbortException {

.....

}
}
When I try to invoke this stored procedure (also using web interface):
exec PriceAdd 0, 'label', 12.1;
I receive this response:
Error: VOLTDB ERROR: PROCEDURE PriceAdd TYPE ERROR FOR PARAMETER 2: tryToMakeCompatible: Unable to match parameters or out of range for taget param: float to provided java.lang.String
(I have also tried without commas, wrapping the float value between ticks and some other tries).
How can be such a stored procedure called ?
We don't support the Java type "float".
jhugg
May 11, 2012
VoltDB's floating point type is an IEEE-754 double-precision value. In SQL, the type is FLOAT. In Java, the type is double or Double. We actually don't support the float type as a parameter.
I've created https://issues.voltdb.com/browse/ENG-2995 to make the VoltCompiler give an error when it sees a "float". Sorry about that.
To fix your program, change the float type to a double in the parameter list.