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



My java code : 

[code]

PreparedStatement preparedStatement = null;
                ListinoVO listinoVO = (ListinoVO) voInterface;
                String insQry = "INSERT INTO " + getTableName() + "
(CODCLI,CODPRO,SCONTPERC,SCONTOEURO) ";
                insQry += "VALUES (?,?,?,?)";
                try
                {
                        preparedStatement = conn.prepareStatement(insQry);
                        preparedStatement.setLong(1,
listinoVO.getCliente().getCodCli().longValue());
                        preparedStatement.setLong(2,
listinoVO.getProdotto().getCodPro().longValue());

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

                        int result = preparedStatement.executeUpdate();

[/code]


My table

[code]

COLUMN_NAME        
|TYPE_NAME|DEC&|NUM&|COLUM&|COLUMN_DEF|CHAR_OCTE&|IS_NULL&
------------------------------------------------------------------------------
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     

[/code]


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.

Reply via email to