Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Mon, 15 May 2006 @ 11:41:33 GMT


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


Subj:   Re: Duplicate unique prime key error
 
From:   Victor Sokovin

  The above query encounters the duplicate PI value because it is casting the integer into a 10 character field. The problem arises because an integer requires 11 characters (a sign + 10 digits). With this cast, the least significant digit is lost resulting in two rows with the key value of ' 1'.  


It is probably confusing to call the default data type conversion (INT to CHAR(n), in this case) "casting" because explicit CAST gives different results.

In Glenn's notation:

     insert into test2(c1, i1)
     select cast(i1 as char(10)), i1
     from test;

This statement does not seem to truncate integers the way the database does when it is implicitly converting data types.


Regards,

Victor



     
  <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