Quote Originally Posted by sumit View Post
I am using a "select for update" with order by clause which is getting a deadlock. I was expecting that adding an order by should never lead to a deadlock, assuming the rows selected FOR UPDATE are locked in the order as
they are returned.

But is that true? Are the rows selected FOR UPDATE locked in the same
order as they are returned (as specified in ORDER BY)? If yes, why am I getting a deadlock?

P.S: transactions are getting committed by each session after 100 records (1 commit on each 100 records).
Is "select for update" populating a cursor?

In the affirmative case, since locks are held for the duration of the transaction, when using an explicit cursor and "for update" option you should not commit across fecthes.