永发信息网

oracle游标体里进行查询,查询条件是变量,当变量为null或者'',查询不到东西。

答案:4  悬赏:0  手机版
解决时间 2021-01-26 19:56
  • 提问者网友:那叫心脏的地方装的都是你
  • 2021-01-26 05:31
oracle游标体里进行查询,查询条件是变量,当变量为null或者'',查询不到东西。
以下语句查不到东西,当value1为''或者null时,
select * from table1 where c1=value1
但我的确有为空的数据,select * from table1 where c1 is null能查到

写成select * from table1 where c1 is value1又报语法错误……
请问这个动态sql条件应该怎么写
最佳答案
  • 五星知识达人网友:摆渡翁
  • 2021-01-26 06:40
因为 原来是 where 值=值
空的查询则是 where is null 不一样
可以在查询前判断是不是空 ,空就换另外的查询语句
全部回答
  • 1楼网友:猎心人
  • 2021-01-26 08:58
好发展
  • 2楼网友:woshuo
  • 2021-01-26 08:23
你好! select * from table1 where c1=value1 or c1 is null 我的回答你还满意吗~~
  • 3楼网友:玩世
  • 2021-01-26 06:50
if value1 is null then select * from table1 where c1 is null; elsif select * from table1 where c1=value1; end if
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯