|
|
Archives of the TeradataForum
Message Posted: Mon, 15 May 2006 @ 11:41:33 GMT
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
| |