不能那样写,但是可以这样写
cursor xx is
SELECT case a when 1 then t1.field1, t1.field2, t1.field3...t1.fieldn
when 2 then t2.field1, t2.field2, t2.field3...t2.fieldn
ELSE NULL END
FROM table1 t1, table2 t2
如果是查询条件,可以用case when 构建,表的话好像没什么好办法。
有个办法,比较麻烦,
建一个临时表table3 like table1
if (a=1) then
insert into table3 select * from table1;
elsif (a=2) then
insert into table3 select * from table2;
end if;
cursor XX is
select * from table3