check if there are records in db before sending the response

Change-Id: I61d51cac12afe001992fe711fa0749ea17459c40