COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: Arsenal on 16 May 2008 11:25:11 AM

Title: Case or If/Then - Generic Question
Post by: Arsenal on 16 May 2008 11:25:11 AM
Hi guys,

I have a general programming question that maybe relates to load handling.

Given a choice, which one should be preferred? A Case statement or an If/Then/Else logic? Is there more processing involved in one or the other, or is it the same for both?

Thanks
Title: Re: Case or If/Then - Generic Question
Post by: blom0344 on 16 May 2008 03:24:26 PM
Hard to tell. In fact, the expressions you define are used by the server's UDA to compile the proper SQL syntax for the database you are addressing. So , in fact the 'IF THEN ELSE' would probably make some sense with SQL servers T-sql. However, non-procedural SQL in other databases need to work with CASE statements , cause outside procedures the SQL compiler can't work with If Then Else.

Bottom-line: CASE is more generic, UDA will recompile (all) the COgnos SQL at runtime and I doubt there will be much of a difference.
Title: Re: Case or If/Then - Generic Question
Post by: almeids on 19 May 2008 08:58:42 AM
I haven't seen a (performance) difference in my experience; my rule of thumb is to use CASE just for readability whenever the condition would require nesting IFs.