Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> ORA-02298 When create FK refering to a Unique Constraint

ORA-02298 When create FK refering to a Unique Constraint

From: <xtanto_at_hotmail.com>
Date: 9 Apr 2006 20:14:21 -0700
Message-ID: <1144638861.234668.211770@g10g2000cwb.googlegroups.com>


Hi All,

I get error when trying to create Foreign Key to a Table, not referring to a PK But to a UNIQUE Constraint.

I can create FK event not refering to PK as long as that table has UNIQUE constraint on that specific column, can't I ?

CREATE TABLE INVOICE
(

  NODOKUMEN    VARCHAR2(30 BYTE)                NOT NULL,
  COMPID       VARCHAR2(5 BYTE)                 NOT NULL,
  ...
  FAKTURPAJAK VARCHAR2(30 BYTE),
  UPDATETIME DATE
)

ALTER TABLE INVOICE ADD (
  CONSTRAINT INVOICE_PK PRIMARY KEY (NODOKUMEN) USING INDEX ... ALTER TABLE INVOICE ADD (
  CONSTRAINT INVOICE_U01 UNIQUE (FAKTURPAJAK) USING INDEX .. CREATE TABLE PAYMENT
(

  FAKTURNO VARCHAR2(30 BYTE) NOT NULL,   .....
  UPDATETIME DATE ) ALTER TABLE PAYMENT ADD (
  CONSTRAINT PAYMENT_PK PRIMARY KEY (FAKTURNO) USING INDEX ..... ALTER TABLE PAYMENT
 ADD CONSTRAINT PAYMENT_R01 FOREIGN KEY (FAKTURNO)  REFERENCES INVOICE (FAKTURPAJAK); ERROR at line 2:
ORA-02298: cannot validate (PAYMENT_R01) - parent keys not found

How can I solve this problem ?

Thank you,
xtanto Received on Sun Apr 09 2006 - 22:14:21 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US