parent keys not found?

parent keys not found?

Post by Stefanita Vilc » Sun, 31 Dec 1899 09:00:00



hello,

I am trying to add a foreign key to a table but I receive:

SQL>   ALTER TABLE PLATI ADD CONSTRAINT fk_PLATI_pid FOREIGN KEY (pid)
REFERENCES PRIMA (pid);
  ALTER TABLE PLATI ADD CONSTRAINT fk_PLATI_pid FOREIGN KEY (pid)
REFERENCES PRIMA (pid)
*
ERROR at line 1:
ORA-02298: cannot enable (DNTB.FK_PLATI_PID) - parent keys not found

The parent key exists and is enabled. Is there anything elese I should
do?

TIA

-vsv

SQL>  select * from all_constraints where
constraint_name='PK_PRIMA_PID';

OWNER                          CONSTRAINT_NAME                C
TABLE_NAME                    
SEARCH_CONDITION                                                                
R_OWNER                        R_CONSTRAINT_NAME              DELETE_RU
STATUS   DEFERRABLE     DEFERRED  VALIDATED     GENERATED      BAD
LAST_CHAN
------------------------------ ------------------------------ -
------------------------------
--------------------------------------------------------------------------------
------------------------------ ------------------------------ ---------
-------- -------------- --------- ------------- -------------- ---
---------
DNTB                           PK_PRIMA_PID                   P
PRIMA                                                                                                                                                                                  
ENABLED  NOT DEFERRABLE IMMEDIATE VALIDATED     USER NAME        
02-DEC-99

 
 
 

parent keys not found?

Post by Michel Cado » Sun, 31 Dec 1899 09:00:00


This message does not mean that the primary key of the referenced
table does not exist but that some rows in the table plati have
a pid that is not in the pid column of the prima table.
You can check that with the query:
select * from plati
where not exists (select null from prima
                  where prima.pid = plati.pid);

--
Have a nice day
Michel



Quote:> hello,

> I am trying to add a foreign key to a table but I receive:

> SQL>   ALTER TABLE PLATI ADD CONSTRAINT fk_PLATI_pid FOREIGN KEY (pid)
> REFERENCES PRIMA (pid);
>   ALTER TABLE PLATI ADD CONSTRAINT fk_PLATI_pid FOREIGN KEY (pid)
> REFERENCES PRIMA (pid)
> *
> ERROR at line 1:
> ORA-02298: cannot enable (DNTB.FK_PLATI_PID) - parent keys not found

> The parent key exists and is enabled. Is there anything elese I should
> do?

> TIA

> -vsv

> SQL>  select * from all_constraints where
> constraint_name='PK_PRIMA_PID';

> OWNER                          CONSTRAINT_NAME                C
> TABLE_NAME
> SEARCH_CONDITION
> R_OWNER                        R_CONSTRAINT_NAME              DELETE_RU
> STATUS   DEFERRABLE     DEFERRED  VALIDATED     GENERATED      BAD
> LAST_CHAN
> ------------------------------ ------------------------------ -
> ------------------------------
> ------------------------------------------------------------------------------
--
> ------------------------------ ------------------------------ ---------
> -------- -------------- --------- ------------- -------------- ---
> ---------
> DNTB                           PK_PRIMA_PID                   P
> PRIMA
> ENABLED  NOT DEFERRABLE IMMEDIATE VALIDATED     USER NAME
> 02-DEC-99


 
 
 

1. SOS:ora-02298:parent keys not found

Hello,I have an urgent problem.PLEASE HELP ME!

I have 2 tables:

TABLE1                  TABLE2
---------------------------------------    ---------------------------
accept_no        char(8)             ord_no         char(8)
accept_num    char(3)              ord_num     char(3)
ord_no              char(8)              ord_qty        number(11,4)
ord_num          char(3)              ord_date      char(8)
accept_mark  char(1)              ord_mark    char(1)
chk_qty             number(11,4)

The primary key of TABLE1 is : accept_no+accept_num
The primary key of TABLE2 is :ord_no+ord_num

And TABLE1 has a foreign key (ord_no,ord_num) reference
TABLE2 (ord_no,ord_num)

But when I alter table add the constraint,there is an error:
ORA-02298:cannot enable-parent keys not found.
Why??
Please Help me,Thank you so............... much!!!

2. Measures Incorrect

3. ORA-02298 cannot enable name - parent keys not found

4. Executing code while SS7 stored procedure is crunching

5. error 02291 "parent key not found" (help for newbie)

6. Newbie Disk Drive Question

7. please help : newbie question - 'parent keys not found'

8. DSO Object Model: Where are Calculated Members?

9. parent key column lost in parent/child dimension

10. keys allowed in child which do not exist in parent table when restoring using pg_restore

11. ERROR: Parent tuple was not found

12. Help (2nd request) with determining parent key foreign key relationship

13. Search Key not found in any record.