I have the data in two table having similar column structure, i want to loop it through the data of these two tables
based on certain condition and at run time i want to put the query in for loop, example is given, Please help me
create table ab(a number, b varchar2(20));
insert into ab
select rownum, rownum||'sample'
from dual
connect by level <=10
create table bc(a number, b varchar2(20));
insert into bc
select rownum+1, rownum+1||'sample'
from dual
connect by level <=10
declare
l_statement varchar2(2000);
bool boolean;
begin
bool := true;
if true then
l_statement:='select * from ab';
else
l_statement:='select * from bc';
end if
for iĀ in execute immediate l_statementĀ -- something like this but i am not sure
loop
dbms_output.put_line(i.a);
end loop;
end;
Something like this but this is not a working peace of code.