Function to list records in database