ORA-12899 after object table update

562 views Asked by At
UPDATE ta_1 SET v_1 = 'new value' WHERE v_1 = 'value';
UPDATE ta_1 SET v_1 = 'newest value';

First update query returns exception ORA-12899 and second doesn't when executed on this table:

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) ) ;

First update query returns:

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

With disabled constraint on table both update queries works. Tested on Oracle-XE 10g2. Is it a bug or in some Oracle manual it's written it is a feature?

1

There are 1 answers

0
APC On

Running this on Oracle 11gR2 EE (with the constraint enabled):

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> 

So, maybe it is a bug in XE. Any reason why you're not running the latest version of it?