Teradata CHAR datatype not storing NUMERIC values

General
Enthusiast

Teradata CHAR datatype not storing NUMERIC values

Hi

I am trying to store some numeric values in a field. however when I am trying to select that field it is not showing me proper result.

eg:

create volatile table test

(

age char(3)

)

on commit preserve rows

;

insert into test

values(234);

sel * from test;  -- Output BLANK

insert into test

values(23);

sel * from test;  -- Output 2

Can someone explain why it is not diplaying proper output and what is the correct method of inserting and selecting such records.

Thanks in advance.

Nitin 'Raj' Srivastava

2 REPLIES
Junior Supporter

Re: Teradata CHAR datatype not storing NUMERIC values

Nitin:

SELECT TYPE(234);

 *** Query completed. One row found. One column returned.

 *** Total elapsed time was 1 second.

Type(234)

---------------------------------------

SMALLINT

SMALLINT=> 5 digits + sign = 6 digits:

SELECT '*' || 234 || '*';

 *** Query completed. One row found. One column returned.

 *** Total elapsed time was 1 second.

(('*'||234)||'*')

-----------------

*   234*

Three leading blanks into your CHAR(3).= Output Blank.

SELECT TYPE(23);

 *** Query completed. One row found. One column returned.

 *** Total elapsed time was 1 second.

Type(23)

---------------------------------------

BYTEINT

BYTEINT=> 3 digits + sign = 4 digits:

SELECT '*' || 23 || '*';

 *** Query completed. One row found. One column returned.

 *** Total elapsed time was 1 second.

(('*'||23)||'*')

----------------

*  23*

Two leading blanks + the first digit (2) into your CHAR(3). = Output 2.

HTH.

Cheers.

Carlos.

Fan

Re: Teradata CHAR datatype not storing NUMERIC values

Hi 

Have tried inserting like

insert into test

values('23');

insert into test 

values ('234'); 

HTH

Irfan