比如在存储过程中:
if A=1 then
select A.A1 from A ;
elseif A=2 then
select B.B1 from B;
endif以上语句用decode能办到么??
有没有一个函数,可以执行符合SQL语法的字符串?如果有的话(假设函数名为excsql),我的设想是:
excsql(decode(A,1,'select A.A1 from A',2,'select B.B1 from B'))
if A=1 then
select A.A1 from A ;
elseif A=2 then
select B.B1 from B;
endif以上语句用decode能办到么??
有没有一个函数,可以执行符合SQL语法的字符串?如果有的话(假设函数名为excsql),我的设想是:
excsql(decode(A,1,'select A.A1 from A',2,'select B.B1 from B'))
------------------------------
1
如果子查询返回的是多行,怎么办?
select A.A1 from A where &A=1 union select B.B1 from B where &A=2;
from dual;execute immediate exsql;