I need to fire the same query on multiple tables. Query might return zero, one or more number of rows.
I can loop through the tables using EXECUTE IMMEDIATE
but for returning multiple rows I would need a datatype so I think I would need to keep it as CURSOR
.
for ease, lets say I need to execute below query on 2 tables - table1 and table2
Table1 has following columns
datetime
device_name
value1
value2
Table2 has following columns
datetime
device_name
value3
value4
Query to be executed on both the tables as below:
select datetime, count(*) from table_name group by datetime;
Whats the best approach here?
please note that I can't create any DB objects (proc/function). Has to be anonymous block only.