Subject Re: [Firebird-Java] numeric(15,2) and number of decimal places
Author Steve Wiser
Thanks, we will try it out!

-steve

Roman Rokytskyy wrote:
>
> > It is strange because I am pretty sure that using Interclient it would
> > set the scale to 2 even though the database was storing the value as a
> > double. I will have to confirm this though.
>
> Hmmm... looks that we can do more in this case. In dialect 1 Firebird
> also returns the scale. So far Jaybird has ignored it as there were no
> case where it was not 0.
>
> I have to check whether checking it won't have any negative consequences
> in dialect 3, but in the meantime you can modify following methods in
> FBDoubleField:
>
> public double getDouble() throws SQLException {
> if (getFieldData()==null) return DOUBLE_NULL_VALUE;
>
> double result = field.decodeDouble(getFieldData());
>
> if (field.sqlscale != 0) {
> BigDecimal tempValue = BigDecimal.valueOf(result);
> tempValue = tempValue.setScale(
> Math.abs(field.sqlscale),
> BigDecimal.ROUND_HALF_EVEN);
> result = tempValue.doubleValue();
> }
>
> return result;
> }
> public BigDecimal getBigDecimal() throws SQLException {
> if (getFieldData()==null) return BIGDECIMAL_NULL_VALUE;
>
> BigDecimal result =
> new BigDecimal(field.decodeDouble(getFieldData()));
>
> if (field.sqlscale != 0)
> result = result.setScale(
> Math.abs(field.sqlscale),
> BigDecimal.ROUND_HALF_EVEN);
>
> return result;
> }
>
> Roman
>
>