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

 

QE-DEF-0405 Incompatible data types in case statement Relational Report Studio.

Started by gosoccer, 01 Feb 2017 09:43:43 AM

Previous topic - Next topic

gosoccer

Hi,

I'm getting an error since the CAR_TYPE is an integer, but I need to present  the CAR_TYPE = 1 as '1-10'
in the Report like what the mock up shows.

Of course, the below Case Statement will give me the error:

QE-DEF-0405    Incompatible data types in case statement Relational Report Studio.

case

when [View].[CAR_TYPE]= '01' then '1-10'
when [View].[CAR_TYPE]= '02' then '11-20'

ELSE

[View].[CAR_TYPE]

END

Any recommendations, I'll greatly appreciate it.
:) :)

MFGF

Quote from: gosoccer on 01 Feb 2017 09:43:43 AM
Hi,

I'm getting an error since the CAR_TYPE is an integer, but I need to present  the CAR_TYPE = 1 as '1-10'
in the Report like what the mock up shows.

Of course, the below Case Statement will give me the error:

QE-DEF-0405    Incompatible data types in case statement Relational Report Studio.

case

when [View].[CAR_TYPE]= '01' then '1-10'
when [View].[CAR_TYPE]= '02' then '11-20'

ELSE

[View].[CAR_TYPE]

END

Any recommendations, I'll greatly appreciate it.
:) :)

How about

case

when [View].[CAR_TYPE]= 1 then '1-10'
when [View].[CAR_TYPE]= 2 then '11-20'

ELSE

cast([View].[CAR_TYPE], varchar(2))

END
Meep!

gosoccer


dougp

I think you'll want varchar(5) to be comatible with values like "11-20".  To reduce the confusion (for Cognos) you'll probably want to wrap the whole think in a cast statement.  That will reduce the ambiguity since "1-10" is 4 characters and "11-20" is 5 characters.  If Cognos doesn't know the exact data type, aggregation may get weird (at least in 10.2.1).


cast(
    case
        when [View].[CAR_TYPE]= 1 then '1-10'
        when [View].[CAR_TYPE]= 2 then '11-20'
        else cast([View].[CAR_TYPE], varchar(5))
    end
    , varchar(5)
)