0

I have to iterate over each row in SQLITE JDBC on-memory table in order to update the cell value of one of the columns using the cell value of another column in the same row.

E.g. For each row in the table, take cell value of column 3, make some minor changes and put this value in cell of column 6 in the same row.

What would be the best approach for this, lie most optimized way of doing this.

So the main question is how to iterate over each row in table. I am not sure if it's a valid question. But would like to know suggestions or perhaps some sample snippet.

opalenzuela
  • 3,139
  • 21
  • 41
Indigo
  • 2,887
  • 11
  • 52
  • 83
  • What is that "minor change"? – CL. Nov 14 '13 at 18:02
  • The change is to update the cell value using another cell value of the same row, although, here the what's the change is not that important. The main task is how to update that or even insert a new value there. – Indigo Nov 21 '13 at 10:39

1 Answers1

0

You can use any SQL expression in the UPDATE statement:

stmt.executeUpdate("UPDATE MyTable SET Col6 = Col3 + 123");
CL.
  • 173,858
  • 17
  • 217
  • 259