【发布时间】:2014-05-09 19:21:26
【问题描述】:
有没有办法获取最后一个更新的行ID,就像我们可以从insert操作中得到的那样?
int row_id = -1
// fx_watchlist_id is having constraint unique (fx_watchlist_id) on conflict.
// So, we are pretty sure maximum updated row will be 1
int count = database.update(TABLE_TIMESTAMP, values, "fx_watchlist_id = ?", new String[]{Long.toString(fxWatchlistId)});
if (count <= 0) {
row_id = database.insert(TABLE_TIMESTAMP, null, values);
} else {
// Is there a way to retrieve last updated row id, without perform select?
row_id = ...
}
return row_id;
【问题讨论】: