I have a procedure body with a loop on the results of a query:
for src in (
/* query A */
) loop
/*
* loop body...
*/
end loop;
But I need to select between two or more different 'query A's depending on some condition. The queries are very different, but they all have the same resulting shape, namely one number column.
Is there a way to avoid having to repeat the loop code? Can I do something like this?
if /* some condition */ then
query_A := /* ... */;
else
query_A := /* ... */;
end if;
for src in (query_A) loop
/*
* loop body...
*/
end loop;
I'm on Oracle 11g