update table set lock=$$ where id=foo and lock=0