If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

getting error with the case statement

Started by devardekartb, 30 Sep 2015 05:39:06 AM

Previous topic - Next topic

devardekartb


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.

BigChris

case
when  [PROPOSED_GHO_CODE] is not missing then [PROPOSED_GHO_CODE]
else [ORIGINAL_GHO_CODE]
end

Lynn

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.