Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 15 Sep 2009 @ 15:11:07 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: INTEGER to VARCHAR data conversion strange
 
From:   Fred W Pluebell

1) You didn't specify a FORMAT for the implicit conversion. The default INTEGER format is '-(10)9' (unless you change that via tdlocaledef). Implicit CAST follows Teradata rules, so the result is 11 characters long to allow for the optional sign. The INSERT SELECT takes the first 10 characters from the converted string (truncating the low-order digit), trims any trailing spaces, and inserts the result.

2) The constant value 13333 is not INTEGER, it's SMALLINT. The default format is '-(5)9', again to allow for the optional sign, so after the implicit CAST it's 6 characters long. The constant '13333' is VARCHAR(5) CHARACTER SET UNICODE.

3) The implicit CAST behavior is different because the underlying data types are different.

Also notice the difference if you use explicit ANSI-style CAST:

     insert into my_tabch sel cast(cl1 as VARCHAR(10)) from my_tab;

In this case, leading AND trailing spaces are trimmed (so there is no truncation).



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023