Trouble with Format

Database
Enthusiast

Trouble with Format

Hi,

I am trying to format a column of type integer using the format() function.

The SQL is somewhat like:

select phone_no(format '999-999-9999') from cust_returns

I am running this from the SQL assistant and it doesn't work. The data is displayed in its original form with "," seperators and format() has no effect.

Am I missing anything?

Appreciate your help.

Thanks

Tags (1)
2 REPLIES
Senior Apprentice

Re: Trouble with Format

FORMAT is only applied when there's a CAST from/to a string.

Only for BTEQ REPORTs it's done automatically, for anything else you need to add a CAST to a [VAR]CHAR, most datatypes also work with a simple TRIM:

trim(phone_no(format '999-999-9999'))
or
phone_no(format '999-999-9999') (char(12))
Enthusiast

Re: Trouble with Format

It works.

Thanks for your quick response.