作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个带有这样的可选参数的存储过程
create or replace
PROCEDURE "my_stored_procedure" (param1 int, param2 int default null)
IS
BEGIN
[select some fields from some tables]
...
我需要一个在默认参数上带有 if 的 where
子句(如果已设置),但我什至不知道这是否可能...
类似于
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
这可能吗?
最佳答案
在这种情况下你可以这样做:
where param1=123 and (param2 is null or param2 != some_value)
如果 param2 不为 null - 则仅当 param2 != some_value
时才为 true - 正如预期的
如果 param2 为 null - 那么无论 some_value
是什么,它都会返回 true
关于Oracle 和 where 子句中的可选存储过程参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17852534/
我正在尝试用 Swift 编写这段 JavaScript 代码:k_combinations 到目前为止,我在 Swift 中有这个: import Foundation import Cocoa e
我是一名优秀的程序员,十分优秀!