I have a table
create table BD_VEHICLES_TEMP_1
(
CONTRACT_NO VARCHAR2(16) not null,
ELIMINATED_FLG VARCHAR2(1),
ELIMINATION_CODE VARCHAR2(2),
PUBLISHED VARCHAR2(1),
BD_GRP_ID VARCHAR2(10),
EMD NUMBER(8),
VALUATION_PRICE NUMBER(8),
DIVI VARCHAR2(2),
)
I have made a corresponding bean
and setting the value of its attribute as
bean.setDIVI(row.getCell(27).getNumericCellValue()+"");
however while inserting the bean into database i get the following error
ORA-12899: value too large for column "AFSWEB"."BD_VEHICLES_TEMP_1"."DIVI" (actual: 4, maximum: 2)
I know that this has something to do with size of column. Data in excel sheet for DIVI is 11,13,45,67.. and so on all 2 digits.
What can be the reason ? What is the solution ?
Thanks in advance !
From the Cell.getNumericCell() javadocs you'll see that it returns a double
. You appear to be trying to use a rather odd technique to turn that into a string, and your chosen way of double+""
is very likely to produce long strings, as a double will often have lots of digits after the decimal point!
From your table definition:
DIVI VARCHAR2(2),
I gather that you're trying to turn the numeric cell into a two digit string. I'm not sure why you want to do that, rather than storing an INTEGER
in your database, but I'm hoping you have a good reason.... Assuming so, you should do something with DataFormatter like
DataFormatter fmt = new DataFormatter();
String divi = fmt.formatCellValue(row.getCell(27).getNumericCellValue());
if (divi.length() > 2) {
throw new IllegalStateException("Row should contain a 2 digit number, found " + divi);
}
bean.setDIVI(divi);