【发布时间】:2013-07-25 08:12:49
【问题描述】:
我有一个带有像这样的可选参数的存储过程
create or replace
PROCEDURE "my_stored_procedure" (param1 int, param2 int default null)
IS
BEGIN
[select some fields from some tables]
...
我需要一个 where 子句,在默认参数上带有 if (如果已设置),但我什至不知道这是否可能......
类似
where param1=123 and (if param2 is not null then some_value != param2)
select 子句又长又复杂,所以我更喜欢有一个“灵活的”WHERE 而不是像这样的结构
if param2 is not null then
[long and complex select] where param1=123 and some_value != param2
else
[long and complex select] where param1=123
这可能吗?
【问题讨论】: