db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marco Rico-Gomez <m.ricogo...@googlemail.com>
Subject Re: Arithmetic operations and PreparedStatments
Date Wed, 02 Feb 2011 22:33:49 GMT

>> update T_Professor set weight_In_B_D = ((((weight_In_B_D + ?) - ?) *
>> ?) / ?) where (id = ?)
> 
> I'm not sure why the arithmetic is carried out using different
> intermediate scale and precision when you use dynamically substituted
> values for the constants in your expressions.
> 
> Did you try using the SQL CAST() operator? Does that help at all?

I tried it: Adding CAST() to decimal solves the problem. However,  binding
BigDecimals to the PreparedStatement without explicit CAST() to decimal
should work as well, IMHO !?!

> 
> There might be a way to use Derby stored procedures to enable you
> to implement the numeric processing in your own Java code, rather
> than in SQL, which could be a workaround.
> 
> The behavior you are seeing has the feel of a bug, though it's
> certainly possible it could be defined SQL language behavior. But since
> you have such a nicely-constructed test program, I think you should
> file your issue in the Derby bug-tracking system so that the developers
> can analyze it in more detail.
> 
> http://db.apache.org/derby/DerbyBugGuidelines.html

Just filed an issue: https://issues.apache.org/jira/browse/DERBY-4998

Thanks!

Mime
View raw message