Link to home
Start Free TrialLog in
Avatar of k_murli_krishna
k_murli_krishnaFlag for India

asked on

SQL0406 Conversion Error in AS/400 DB2 from Java

1) We have database schema in iseries AS/400 DB2 V5R3
2) On a insert statement we are getting error SQL0406 Conversion Error on assignment to column.
3) We know the column and same column DECIMAL(13,2) is in 2 tables. We are taking value from 1st table column via screen and Java code where we apply BigDecimal and scale and inserting into 2nd table column.
4) There are no calculations/formulae in between. One case where this error may occur is we exceed the digits before decimal point allowed i.e. 11. But this huge a number is unable to occur.
5) After decimal we can have 2 digits. In Linux DB2, if we give more than 2 also, truncation to 2 digits occurs and insert is successful. Is this the case in AS/400 DB2. We do not have access here to test.
6) 1 particular value which failed is 53489.93. Since value is taken from source column DECIMAL(13,2) and inserted in target column DECIMAL(13,2) it looks straight.
7) But the devil must be lurking in JDBC driver jt400.jar or Java code where they convert value to BigDecimal and set scale upto 2 digits.
8) The value of the column TOTAL_PREMIUM is exceeding normal length and hence: TOTAL_PREMIUM  FOR COLUMN FLD03430 DECIMAL(13, 2) NOT NULL DEFAULT 0
It is exactly same way in both tables. Could this be the culprit in any way?
ASKER CERTIFIED SOLUTION
Avatar of Gary Patterson, CISSP
Gary Patterson, CISSP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of k_murli_krishna

ASKER

Thanks Gary.
Happy to help.  Were you able to resolve the problem, and if so, what  did it?
Not yet. It is enmeshed in Java and my peer senior developers are working on it Your post is a good help towards that. It was simulated in production once and after that it is not occurring again.
Feel free to reopen the question if you need more help.

- Gary