db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Rehlig" <reh...@lemonage.de>
Subject AW: The resulting value is outside the range for the data type DECIMAL/NUMERIC(4,4).
Date Tue, 08 Sep 2009 08:21:37 GMT
Have you tried setting the scale of your new BigDecimal(BigInteger.ZERO) ?

Something like:

BigDecimal value = new BigDecimal(BigInteger.ZERO);
value.setScale(8, new MathContext(19, RoundingMode.HALF_UP));

where the MathContext sets the precision of your BigDecimals...

-----Urspr√ľngliche Nachricht-----
Von: pedro [mailto:pedro.riky@libero.it] 
Gesendet: Dienstag, 8. September 2009 10:09
An: derby-user@db.apache.org
Betreff: The resulting value is outside the range for the data type DECIMAL/NUMERIC(4,4).

Hi all i have this error on insert but i don't understand why because i
insert almost 4 decimals BigDecimal.

My java code : 


PreparedStatement preparedStatement = null;
		ListinoVO listinoVO = (ListinoVO) voInterface;
		String insQry = "INSERT INTO " + getTableName() + "
		insQry += "VALUES (?,?,?,?)";
			preparedStatement = conn.prepareStatement(insQry);

			// Se no si porta dietro n cifre e Derby(DB) va in errore
	BigDecimal sconto =
			preparedStatement.setBigDecimal(3, new BigDecimal(BigInteger.ZERO));
			preparedStatement.setBigDecimal(4, sconto);

			int result = preparedStatement.executeUpdate();


My table


CODCLI                  |NUMERIC  |0   |10  |12    |NULL      |NULL      |NO      
CODPRO                 |NUMERIC  |0   |10  |12    |NULL      |NULL      |NO      
SCONTPERC            |NUMERIC  |0   |10  |3     |NULL      |NULL      |YES     
SCONTOEURO          |NUMERIC  |4   |10  |4     |NULL      |NULL      |YES     


I try and i found that the problem is SCONTOEURO  but i'm sure, because i
debug by eclipse, that the value is with 4 decimals.

Any idea ?

View this message in context: http://www.nabble.com/The-resulting-value-is-outside-the-range-for-the-data-type-DECIMAL-NUMERIC%284%2C4%29.-tp25341647p25341647.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.

View raw message