[英]check constraint violated temporal
My table definition 我的表定义
CREATE TABLE PROVISION_HIST
(
card_nbr number(9) primary key,
provision_loc_cd varchar2(2),
start_ts timestamp(6),
end_ts timestamp(6),
last_updt_ts timestamp(6),
provision_meta_data xmltype,
unprovision_meta_data xmltype,
PERIOD FOR user_valid_time (start_ts, end_ts)
)
PARTITION BY RANGE (end_ts)
(
PARTITION PROVISION_HIST_P0 VALUES LESS THAN (TO_DATE('10-01-2014', 'MM-DD-YYYY')),
PARTITION PROVISION_HIST_P1 VALUES LESS THAN (TO_DATE('11-01-2014', 'MM-DD-YYYY')),
PARTITION PROVISION_HIST_P2 VALUES LESS THAN (TO_DATE('12-01-2014', 'MM-DD-YYYY')),
PARTITION PROVISION_HIST_P3 VALUES LESS THAN (TO_DATE('01-01-2015', 'MM-DD-YYYY'))
);
CREATE UNIQUE INDEX provision_hist_pk
ON PROVISION_HIST (card_nbr, provision_loc_cd, start_ts);
I JUST NEED TO INSERT SOME DUMMY DATA FOR TESTING. 我只需要插入一些虚拟数据进行测试即可。 SO I USED
所以我用
INSERT INTO provision_hist (CARD_NBR,PROVISION_LOC_CD, START_TS,END_TS,LAST_UPDT_TS,PROVISION_META_DATA,UNPROVISION_META_DATA)
VALUES (4444,'lx',to_timestamp( '03/18/2012 02:35 AM', 'MM/DD/YYYY HH:MI AM'),to_timestamp( '12/01/2014 02:35 AM', 'MM/DD/YYYY HH:MI AM'),current_timestamp(6),'<Warehouse whono="200"><Building>Leased</Building> </Warehouse>','<Warehouse whono="200"> <Building>Leased</Building> </Warehouse>'
);
ORA-02290: check constraint (USER_VALID_TIME793C79) violated ORA-02290:检查约束(USER_VALID_TIME793C79)已违反
Any help would be great. 任何帮助都会很棒。
Thanks. 谢谢。
You have just displayed a variation of a known bug associated with Oracle 12c's temporal validity feature, Bug 18195286 : ORA-2290 ON INSERT INTO TABLE WITH TEMPORAL VALIDITY . 您刚刚显示了与Oracle 12c的时间有效性功能相关的一个已知错误的一个变体,即错误18195286:在具有临时有效性的 表中插入ORA-2290 。
Specifically, when one alters or creates a table with the PERIOD FOR
clause, a constraint is created to validate the dates for the period: 具体来说,当使用
PERIOD FOR
子句更改或创建表时,将创建约束以验证该期间的日期:
PERIOD FOR user_valid_time (start_ts, end_ts)
The constraint created can be displayed by querying user_constraints. 可以通过查询user_constraints来显示创建的约束。 It will show this:
它将显示以下内容:
SELECT search_condition
FROM user_constraints
WHERE table_name = 'PROVISION_HIST'
Results in the constraint: 结果约束:
(start_ts < end_ts) and (VALID > 0)
Your insert statement throws an error with this constraint. 您的insert语句使用此约束引发错误。
Kim Berg Hansen identified this earlier, I am just citing the actual bug. 金·伯格·汉森(Kim Berg Hansen)较早地指出了这一点,我只是引用了实际的错误。 This is identified as being fixed with version 12.1.0.2.
这被确定为在12.1.0.2。版中已修复。
Just by looking at the Insert part the AM of the to_timestamp is bothering me. 仅通过查看“插入”部分,to_timestamp的AM就会困扰我。 How about at least taking out AM because it looks like in http://www.techonthenet.com/oracle/functions/to_timestamp.php , they don't do that.
至少要删除AM,因为看起来像http://www.techonthenet.com/oracle/functions/to_timestamp.php一样 ,他们不这样做。 So first lets take out that.
因此,首先让我们将其取出。 Maybe you also want to change FOR to AS.
也许您还想将FOR更改为AS。 And it seems that user_valid_time is a function because of the parameters it takes in, so I will recommend finding this function and checking its implementation.
似乎user_valid_time是一个函数,因为它接受了参数,因此我建议您找到此函数并检查其实现。 " http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions231.htm "
“ http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions231.htm ”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.