Replace typed queries with cross-database functions