DB2 DECIMAL FORMAT EXCEPTION (URGENT)
843854Nov 14 2002 — edited Nov 21 2002To undersdande my problem, please see the code below:
CODE A:
sql = "INSERT INTO DEC VALUES ('999999999999999.99',999999999999999.99')";
PreparedStatement stmt = con.getConnection().prepareStatement(sql);
stmt.executeUpdate();
CODE B:
sql = "INSERT INTO DEC VALUES (?, ?)";
PreparedStatement stmt = con.getConnection().prepareStatement(sql);
stmt.setString(1, '999999999999999.99');
stmt.setDouble(2, 999999999999999.99);
stmt.executeUpdate();
The Problem:
The table DEC tha I used has two columns, the first is a char(50) and the second is a Decimal(17,2) and its in DB2 running on AIX.
If I execute the firs statement, it execute very well. If I execute the second, the follow exception occurs:
COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2] SQL0302N The value of a host variable in the EXECUTE or OPEN statement is too large for its corresponding use. SQLSTATE=22003
If I reduce on algarism on number (14 digits and two decimals) the result is:
String Decimal
-------------------------------------
CODE A 99999999999999.99, 99999999999999.99
CODE B 99999999999999.99, 100000000000000.00
My question:
Is the code incompatible? Why?
Does anybody knows what is wrong?
I need help urgent!!!
Thanks in advance
Renato Melo