Delegate SQL queries to functions