You could use a dynamic query that uses SQL-generating-SQL.
Examining the pieces:
Dynamic SQL allows you to use the EXEC SQL
command to execute a string as a SQL statement. This is a powerful technique that lets you generate or load a SQL statement into a string and then evaluate it as if it is a normal statement.
SQL-generating-SQL is a technique where we use SQL (typically against the Oracle data dictionary) to produce a string that is itself valid SQL. A simple example is:
SELECT 'SELECT * FROM ' || all_tables.table_name
FROM all_tables
which would produce a result set consisting of strings that are themselves SELECT statements against all of the tables available in your environment.