DIGITS

Database

DIGITS

We are converting DB2 to Teraddata.... in that need to convert one function ...

DB2 >>>
COLUMN1 is INT- (4) ...is it is stored as
1
12
123
If i use DIGITS function as select DIGITS(COLUMN1) .....

output will be
0001
0012
0123

Like this teradata is having any function ????

1 REPLY
Teradata Employee

Re: DIGITS

Use CAST(CAST(COLUMN1 AS FORMAT '9(p)') AS CHAR(p))
Where p is the number of digits in the result.

By the way, lengths used by DB2 are:
SMALLINT - 5
INTEGER - 9
BIGINT - 19

For DECIMAL(p,s) where s <> 0, DB2 omits the decimal point; so you'd need FORMAT '9(p-s)V9(s)'