COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: devardekartb on 30 Sep 2015 05:39:06 AM

Title: getting error with the case statement
Post by: devardekartb on 30 Sep 2015 05:39:06 AM

Hello ,

I am gettitng parsing error when i am taking one query subject and its definition is like below:

case
when  [PROPOSED_GHO_CODE] not in ('null',"") then [PROPOSED_GHO_CODE] else [ORIGINAL_GHO_CODE]
end.

Please advise.
Title: Re: getting error with the case statement
Post by: BigChris on 30 Sep 2015 05:45:23 AM
case
when  [PROPOSED_GHO_CODE] is not missing then [PROPOSED_GHO_CODE]
else [ORIGINAL_GHO_CODE]
end
Title: Re: getting error with the case statement
Post by: Lynn on 30 Sep 2015 06:42:45 AM
Quote from: devardekartb on 30 Sep 2015 05:39:06 AM
Hello ,

I am gettitng parsing error when i am taking one query subject and its definition is like below:

case
when  [PROPOSED_GHO_CODE] not in ('null',"") then [PROPOSED_GHO_CODE] else [ORIGINAL_GHO_CODE]
end.

Please advise.

The solution Chris provided is good, but I suspect you are getting the parsing error because of the double quotes you are using to identify an empty string. These should be single quotes. The parsing error often tells you where in the expression the problem is detected so you should have looked at that to help you solve it or at least passed that information on in your post.

Further, the way you specify null inside single quotes means that you are expecting the proposed GHO code to contain a string with the word null in it which isn't what one would typically expect to find. An alternative to what Chris provided, but closer to the direction you took might be as:


case
  when [PROPOSED_GHO_CODE] is not null and [PROPOSED_GHO_CODE] <> ''
       then [PROPOSED_GHO_CODE]
  else [ORIGINAL_GHO_CODE]
end


Personally I think what Chris provided is a better expression if it works for you.