How to rollback transaction if row changed?
Not sure why you are not updating directly with additional predicates in the where clause, but if that is not possible you can select for update as in:

SELECT * FROM tbl WHERE id = 1 FOR UPDATE


This will lock the selected row and prevent updates of it while you do your validation.