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

Function Case

Started by HERRERA, 22 Nov 2007 01:13:45 PM

Previous topic - Next topic

HERRERA

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

zaith

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?

HERRERA

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