I don't see how you could do this in one sql statement, because as soon as you update the first row you've lost the value you need for the second update. Hence why you need plsql