begin
for cur in(select id,flag fromu a)
loop
if cur.flag=0 then
select * from b;
...
else
select * from C;
...
end if;
end loop;
end;
用动态语句
或试试这样行不行
select * from decode(select flag from a where id=1,0,(select * from b),1,(select * from c))
declare
as_flag varchar2(10);
as_sql varchar2(300);
begin
select FLAG into as_flag from A where ID = 1;
if as_flag = '0' then
select * from b where ....;
else
select * from C where ....;
end if;
end;
declare
as_flag varchar2(10);
as_sql varchar2(300);
begin
select FLAG into as_flag from A where ID = 1;
if as_flag = '0' then
insert into 结果表(xx..xx) select xx..xx from b where ....;
else
insert into 结果表(xx..xx) select xx..xx from c where ....;
end if;
end;