Oracle answer.
Re: How to pull data from several tables that follows a pattern?
Oracle provides Dynamic SQL facilities that would be the basis for a solution.
The main points:
1. You create a "for ... loop ... end loop" to iterate over the table names that follow the pattern.
2. Inside the loop (for each table) you append a sql "select ..." text to form a union of the data in all tables.
3. At the end you execute the constructed sql text.
There can be variations of this solution. You could use the "execute immediate .." construct or the dbms_sql facility.
Or, instead of concatenating, inside the loop you could actually execute the single-table sql.
Hope this helps.
P.S.
[sql]
for t in (SELECT object_name FROM user_objects WHERE object_type='TABLE' and object_name like 'ex_%')
loop
...
end loop
[/sql]
|