0

I have an application which reads data from excel and write it into Oracle DB using Spring BatchSqlUpdate class. The values are getting properly inserted for most of the cases but for some rare cases i am getting below issues.

In Spring sql types for one of my column teh type configured as 'BigDecimal', so i will convert the values read from excel to Bigdecimal. I am trying to convert '24445720' to BigDecimal and the result is '2.444572E+7'. I am passing the same value to the update command but the value got inserted as '2444572' the last 0 got truncated.

Code:

   BigDecimal.valueOf (((Number) value).doubleValue ()); //convert value

   //Code used for insert data
   BatchSqlUpdate upd = createBatchUpdate ();
   for (BillEvent event : events) {
   Object params[] = getInsertParamsForEvent (event);
   upd.update (params);
   }
   upd.flush ();​

  private BatchSqlUpdate createBatchUpdate () {
    BatchSqlUpdate upd = new BatchSqlUpdate (ds, insEvent.getSql (), 
    insEventTypes);
    upd.compile ();
    upd.setBatchSize (100);
    upd.setTrackRowsAffected (false);
    return upd;
   }​

Please help

  • Oke, the problem is clear, but its location... so the loss (of scale) happens in `update` (have you verified via log/debugger?) - if so, then please show us: `createBatchUpdate()`.. – xerx593 Oct 17 '17 at 21:04
  • Hi xerx593, added createBatchUpdate() method. Please check – user3800354 Oct 18 '17 at 07:46
  • Column type `NUMBER(7)`? – Joop Eggen Oct 18 '17 at 11:34
  • Yes Eggen column type is NUMBER. I didnt faced any issue while the input is 60000000, it was converted into Bigdecimal as 6.0E+7 and persisted successfully. Whenever the input value ends with 0 ex 24445720, 62346730, 54389750 the last zero got truncated. Please help. – user3800354 Oct 18 '17 at 16:57

0 Answers0