lock record using SOQL so that it cannot be modified by other user
we will need “FOR UPDATE” clause of SOQL.
Account[] accts = [SELECT Id FROM Account LIMIT 2 FOR UPDATE];
SOQL statement can be used to get all records even from recycle bin Apex from Custom button or Javascript : Ajax toolkit