日期:2014-05-17 浏览次数:21103 次
-- 用存储过程封装这两个SQL语句,然后调用存储过程:
-- 存储过程传入一个参数:当参数为1时,执行SQL1;当参数为2时,执行SQL2
create procedure sql_if_proc(sql_if number)
is
begin
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 .....
有什么不一样。