有沒有可以告訴Netezza忽略無效日期的選項或設置?在下面的例子中整個INSERT失敗,因爲源表的第三行有一個無效的日期。我期望違規行可能會被跳過,但插入零行似乎是一個極端的事情。Netezza INSERT - 忽略無效日期?
我嘗試了以下,但它也失敗了。另一種方法是解析源日期和檢驗的有效性每個組件(包括天/月,閏年等)
insert into db.test (cmclmn, effdt, efftm)
select cmclmn, case when to_date(effdt,'yyyymmdd') is null
then null
else to_date(effdt,'yyyymmdd') end,
cast(lpad(efftm,6,0) as time) as efftm
from db.test_src
;
整個腳本:
CREATE TABLE db.test
(
cmclmn integer,
effdt date,
efftm time
)
DISTRIBUTE ON (cmclmn);
drop table db.test_src;
create table db.test_src
(
cmclmn integer,
effdt integer,
efftm integer)
distribute on (cmclmn);
insert into db.test_src (cmclmn, effdt, efftm) values (1,20140120, 102000);
insert into db.test_src (cmclmn, effdt, efftm) values (2,20140121, 231212);
insert into db.test_src (cmclmn, effdt, efftm) values (3,0,111111);
insert into db.test_src (cmclmn, effdt, efftm) values (4,2014,90909);
insert into db.test (cmclmn, effdt, efftm)
select cmclmn, to_date(effdt,'yyyymmdd'), cast(lpad(efftm,6,0) as time) as efftm
from db.test_src
;