Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

ORA-02298: cannot validate

$
0
0
Hi there,

I am trying to add a foriegn key that references a primary key from another table.
To give a diagram view of it this is what I mean:
http://i46.tinypic.com/3tvtf.jpg


The tables are created as follows:
Code:

CREATE TABLE  "BATCH"
  (        "BATCH-NO" NUMBER(10,0) NOT NULL ENABLE,
        "PART-NO" NUMBER(10,0) NOT NULL ENABLE,
        "FACTORY-NO" NUMBER(5,0) NOT NULL ENABLE,
        "CONTAINER-NO" NUMBER(5,0) NOT NULL ENABLE,
        CONSTRAINT "BATCH_CON" PRIMARY KEY ("BATCH-NO") ENABLE
  )
/

CREATE OR REPLACE TRIGGER  "BI_BATCH"
  before insert on "BATCH"             
  for each row 
begin 
  if :NEW."BATCH-NO" is null then
    select "BATCH_SEQ".nextval into :NEW."BATCH-NO" from dual;
  end if;
end;

/
ALTER TRIGGER  "BI_BATCH" ENABLE
/

Subsequently the serialised-part table:
Code:

CREATE TABLE  "SERIALISED-PART"
  (        "SERIAL-NO" NUMBER,
        "BATCH-NO" NUMBER,
        CONSTRAINT "SERIALISED-PART_PK" PRIMARY KEY ("SERIAL-NO") ENABLE
  )
/

CREATE OR REPLACE TRIGGER  "bi_SERIALISED-PART"
  before insert on "SERIALISED-PART"             
  for each row
begin 
  if :new."SERIAL_NUMBER" is null then
    select "SERIALISED-PART_SEQ".nextval into :new."SERIAL_NUMBER" from dual;
  end if;
end;

/
ALTER TRIGGER  "bi_SERIALISED-PART" ENABLE
/

However when I add a contstraint as a foreign key I get the following error:
ORA-02298: cannot validate (GROUP7_1.SERIALISED-PART_CON) - parent keys not found

This is when I am adding Batch-no from serialised-part TABLE to the BATCH table


Thanks guys and I hope you go easy considering its my first post :D

Viewing all articles
Browse latest Browse all 13329

Trending Articles