function to fetch rows as hash