You try with cursor to get db name and run your code under each db.