简体   繁体   English

Oracle SQL Case语句检查SQL脚本的结果

[英]Oracle SQL Case statement checks the result of a SQL script

I have a very huge query, this query has a lot of Case statements within the select statment. 我有一个非常大的查询,该查询在select语句中有很多Case语句。 Right now I'm struggling with the following case 现在我正在为以下情况而苦苦挣扎

select .... 
   case 
      when (select name from location where document = xyz) != ''
      then <do something>
      else <do something else>
   end
.
.
.

How should I check the condition in the above when statement? 我应该如何检查上述when语句中的条件? It seems to not work right now as it is always entering the else block. 由于它总是进入else块,因此现在似乎不起作用。 All I'm trying to check is if the query returns anything or just null. 我要检查的只是查询是否返回任何内容或仅返回null。

As suggested by the @OldProgrammer I've modified it to the following. 如@OldProgrammer所建议,我已将其修改为以下内容。 It worked. 有效。

select .... 
   case 
      when (select name from location where document = xyz) is not null 
      then <do something>
      else <do something else>
   end
.
.
.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM