如何根据某一变量,执行不同的select语句?
2个select语句完全不同
------解决方案--------------------
- SQL code
-- 用存储过程封装这两个SQL语句,然后调用存储过程:-- 存储过程传入一个参数:当参数为1时,执行SQL1;当参数为2时,执行SQL2create procedure sql_if_proc(sql_if number) isbegin if sql_if=1 then your_sql_here; elsif sql_if=2 then your_other_sql_here; end if;end;/
------解决方案--------------------
select * from aa ....
where 'a' = :变量
and .......
union all
select * from bb ....
where 'a' <> :变量
and .....
--------------------------------------
select * from aa ....
where 1 = :变量
and .......
union all
select * from bb ....
where 2 = :变量
and .....
有什么不一样。