根据参数生成判断语句的问题。超难

morningnet 2011-09-12 04:46:55
我做了一个存储过程,有三个存入参数a,b,c ,参数可能是"true",也可能是"false",存储过程通过参数的值考虑是否执行某个检测,如果a,b,c都是true,则语句如下:
if checkA()=true and checkB()=true and checkC()=true
begin
........
end


如果a=true b=false c=true ,则

if checkA()=true and checkC()=true
begin
........
end


如果a=false b=false c=true ,则

if checkC()=true
begin
........
end


请问怎么能够只用一个if就能够根据参数应该执行那些判断??
...全文
60 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
--小F-- 2011-09-12
  • 打赏
  • 举报
回复
写存储过程 设置3个参数,初始值设置为空
拼接字符串 如果参数没有的话 传空值
geniuswjt 2011-09-12
  • 打赏
  • 举报
回复
你这都不是同一层次的判断,没省事方法,一个个写
kenshu 2011-09-12
  • 打赏
  • 举报
回复
如果多个条件可以使用一个分枝的话,

if (a and 你的真正条件) or (b and 你的真正条件2)
......

如果你真的有32个分枝需要做不同处理,那就真的只能写32个分枝
morningnet 2011-09-12
  • 打赏
  • 举报
回复
方法笨了点,因为我的参数实际上不只3个,5个,2的5次方种选择
dawugui 2011-09-12
  • 打赏
  • 举报
回复
if else?
if checkA()=true and checkB()=true and checkC()=true   
begin
........
end
else
if checkA()=true and checkC()=true
begin
........
end
else
if checkC()=true
begin
........
end

22,206

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧