wait N is for select for update isnt it? wait N seconds if you cant get the row then return error...