Hello friends,
I am facing a a strange problem while creating Foreign Key.
My premary key is already created. Please see below I have given a screen shot. you will understand. Pls help me urgently.
------------------------------------------------------------
SQL> desc medorder;
Name Null? Type
------------------------------- -------- ----
ORDNO NOT NULL VARCHAR2(10)
ADDRESS VARCHAR2(100)
GOODSDELAT VARCHAR2(75)
COMMENTS VARCHAR2(150)
ADVANCE VARCHAR2(10)
MOP VARCHAR2(10)
SQL> SELECT CONSTRAINT_NAME,CONSTRAINT_TYPE,TABLE_NAME FROM USER_CONSTRAINTS
2 WHERE TABLE_NAME='MEDORDER';
CONSTRAINT_NAME C TABLE_NAME
--------------------- - ------------------------------
MEDO_PK P MEDORDER
SQL> DESC MEDORDERCHANGE;
Name Null? Type
------------------------------- -------- ----
ORDNO VARCHAR2(10)
TECH VARCHAR2(255)
COMM VARCHAR2(255)
ACTION VARCHAR2(255)
ADDRESS VARCHAR2(100)
ITEMCODE VARCHAR2(50)
QTY VARCHAR2(10)
AMT VARCHAR2(20)
SRNO NUMBER(4)
DT VARCHAR2(10)
DELADDRESS VARCHAR2(100)
YEAR VARCHAR2(10)
SQL> ALTER TABLE MEDORDERCHANGE
2 ADD(CONSTRAINT MEDOC_ORDNO_FK FOREIGN KEY(ORDNO) REFERENCES MEDORDER(ORDNO));
ALTER TABLE MEDORDERCHANGE
*
ERROR at line 1:
ORA-02298: cannot enable (SCOTT.MEDOC_ORDNO_FK) - parent keys not found
thanks in advance
you can contact me at cyberdyne@softhome.net
I am facing a a strange problem while creating Foreign Key.
My premary key is already created. Please see below I have given a screen shot. you will understand. Pls help me urgently.
------------------------------------------------------------
SQL> desc medorder;
Name Null? Type
------------------------------- -------- ----
ORDNO NOT NULL VARCHAR2(10)
ADDRESS VARCHAR2(100)
GOODSDELAT VARCHAR2(75)
COMMENTS VARCHAR2(150)
ADVANCE VARCHAR2(10)
MOP VARCHAR2(10)
SQL> SELECT CONSTRAINT_NAME,CONSTRAINT_TYPE,TABLE_NAME FROM USER_CONSTRAINTS
2 WHERE TABLE_NAME='MEDORDER';
CONSTRAINT_NAME C TABLE_NAME
--------------------- - ------------------------------
MEDO_PK P MEDORDER
SQL> DESC MEDORDERCHANGE;
Name Null? Type
------------------------------- -------- ----
ORDNO VARCHAR2(10)
TECH VARCHAR2(255)
COMM VARCHAR2(255)
ACTION VARCHAR2(255)
ADDRESS VARCHAR2(100)
ITEMCODE VARCHAR2(50)
QTY VARCHAR2(10)
AMT VARCHAR2(20)
SRNO NUMBER(4)
DT VARCHAR2(10)
DELADDRESS VARCHAR2(100)
YEAR VARCHAR2(10)
SQL> ALTER TABLE MEDORDERCHANGE
2 ADD(CONSTRAINT MEDOC_ORDNO_FK FOREIGN KEY(ORDNO) REFERENCES MEDORDER(ORDNO));
ALTER TABLE MEDORDERCHANGE
*
ERROR at line 1:
ORA-02298: cannot enable (SCOTT.MEDOC_ORDNO_FK) - parent keys not found
thanks in advance
you can contact me at cyberdyne@softhome.net