2011-11-01 60 views
1
UPDATE ta_1 SET v_1 = 'new value' WHERE v_1 = 'value'; 
UPDATE ta_1 SET v_1 = 'newest value'; 

首先更新查詢後返回異常ORA-12899和第二並不時在此表中執行:ORA-12899對象表更新

CREATE OR REPLACE type t_2 AS object 
    (v_1 VARCHAR2 (4000)); 

CREATE OR REPLACE type t_1 AS object 
    (
    v_1 VARCHAR2 (4000), 
    v_2 t_2); 

CREATE TABLE ta_1 OF t_1 
    (CHECK (v_2 IS NULL OR (v_2.v_1 = 'uFonec')) ENABLE 
) ; 

CREATE OR REPLACE TRIGGER ta_1_tr BEFORE 
    INSERT OR 
    UPDATE ON ta_1 FOR EACH ROW DECLARE BEGIN IF :new.v_2 IS NULL THEN :new.v_2 := NEW t_2 ('uFonec') ; 
END IF; 
END; 

INSERT INTO ta_1 VALUES (t_1 ('value', NULL)) ; 

首先更新查詢返回:

SQL Error: ORA-12899: value too large for column "TA_1"."V_2" (actual: 1, maximum: 0)

在表上禁用約束條件時,兩個更新查詢都有效。在Oracle-XE 10g2上測試。這是一個錯誤還是在某些Oracle手冊中寫入它是一個功能?

回答

1

在Oracle 11gR2的EE運行這個(與約束啓用):

SQL> INSERT INTO ta_1 VALUES (t_1 ('other value', t_2 ('blah'))) ; 
INSERT INTO ta_1 VALUES (t_1 ('other value', t_2 ('blah'))) 
* 
ERROR at line 1: 
ORA-02290: check constraint (APC.SYS_C0021529) violated 


SQL> UPDATE ta_1 SET v_1 = 'new value' WHERE v_1 = 'value'; 

1 row updated. 

SQL> UPDATE ta_1 SET v_1 = 'newest value'; 

1 row updated. 

SQL> 

,所以這也許是XE的錯誤。任何你沒有運行最新版本的原因?