Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2013
    Posts
    11

    Unanswered: ORA-02298: cannot validate

    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

  2. #2
    Join Date
    Feb 2013
    Posts
    11
    EDIT: Fixed it, seems I had data in the SPECIALISED-PART table which was causing the error.

    Thought this might help people in the future if they stumble on this thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •