How to supress invalid type for Teradata Insert? -
when inserting data 1 table , teradata performs automatic type cast. example if 1 inserts varchar
date
field , teradata
cast varchar
date
. , works perfect if varchars valid date strings.
however, when teradata
encounters varchar
not valid date
, unable cast , shows error . how can force dirty insert
? want teradata
insert null if it's unable cast (silently ignoring errors)
is there way ?
you can try using calendar table. of depend on structure of data, basically:
insert <your destination table> select <t1.columns>, t2.calendar_date <your table> t1 left join sys_calendar.calendar t2 on t1.<your character date column> = cast (cast(t2.calendar_date date format 'yyyy-mm-dd') char(10))
the formatting depend on column looks like.
instead of inserting column source table, insert calendar_date column calendar table. if date in source table invalid, you'll insert null.
Comments
Post a Comment