COGNOiSe.com - The IBM Cognos Community

Legacy Business Intelligence => COGNOS ReportNet => Report Studio => Topic started by: HERRERA on 22 Nov 2007 01:13:45 PM

Title: Function Case
Post by: HERRERA on 22 Nov 2007 01:13:45 PM
Hi friends.
Im form Brasil, and it is my first topic.
I have a problem with a function case. Im trying convert a field, but i cant.
The function is :

CASE [region_id]

WHEN  ('-1') THEN  ('WORLD')
WHEN  ('1')  THEN  ('EUROPA')
WHEN  ('2')  THEN  ('ASIA')
WHEN  ('3')  THEN  ('AFRICA')
WHEN  ('4')  THEN  ('AMERICA')
WHEN  ('25') THEN  ('OCEANIA')

ELSE [region_id]
END

The following message appears :

QE-DEF-0405
Incompatible data types in case statement.



Where is the problem ?????
Excuse me for my bad english.

Thanks
Herrera
Title: Re: Function Case
Post by: zaith on 22 Nov 2007 01:59:15 PM
Herrera,
    The problem is the data type of [region_id].
     Try this:

CASE [region_id]
WHEN  ('-1') THEN  ('WORLD')
WHEN  ('1')  THEN  ('EUROPA')
WHEN  ('2')  THEN  ('ASIA')
WHEN  ('3')  THEN  ('AFRICA')
WHEN  ('4')  THEN  ('AMERICA')
WHEN  ('25') THEN  ('OCEANIA')
ELSE cast_char([region_id])
END

if your data base is Oracle use cast_varchar or to_char instead cast_char.

certo mano?
Title: Re: Function Case
Post by: HERRERA on 23 Nov 2007 05:41:57 AM
Quote from: zaith on 22 Nov 2007 01:59:15 PM
Herrera,
    The problem is the data type of [region_id].
     Try this:

CASE [region_id]
WHEN  ('-1') THEN  ('WORLD')
WHEN  ('1')  THEN  ('EUROPA')
WHEN  ('2')  THEN  ('ASIA')
WHEN  ('3')  THEN  ('AFRICA')
WHEN  ('4')  THEN  ('AMERICA')
WHEN  ('25') THEN  ('OCEANIA')
ELSE cast_char([region_id])
END

if your data base is Oracle use cast_varchar or to_char instead cast_char.

certo mano?


YES !
Its OK now !

Valeu Camarada !
heheh