An important distinction is that these lock each row individually after the initial query. Many times it would in fact be possible to instead issue the FOR UPDATE up front. Here for example:
SELECT t0.id, t0.description, t0.sequence, t0.x, t0.y FROM DataPoint t0 ORDER BY t0.id DESC for update
SELECT * FROM (SELECT t0.id, t0.description, t0.sequence, t0.x, t0.y FROM DataPoint t0 ORDER BY t0.id DESC) WHERE ROWNUM <= ?
Oracle is little touchy about when FOR UPDATE can be applied however. It is invalid on queries that do distinct or grouping. May or may not be invalid on general aggregation queries (select max(...) from ..., etc)
An important distinction is that these lock each row individually after the initial query. Many times it would in fact be possible to instead issue the FOR UPDATE up front. Here for example:
SELECT t0.id, t0.description, t0.sequence, t0.x, t0.y FROM DataPoint t0 ORDER BY t0.id DESC for update SELECT * FROM (SELECT t0.id, t0.description, t0.sequence, t0.x, t0.y FROM DataPoint t0 ORDER BY t0.id DESC) WHERE ROWNUM <= ?Oracle is little touchy about when FOR UPDATE can be applied however. It is invalid on queries that do distinct or grouping. May or may not be invalid on general aggregation queries (select max(...) from ..., etc)