Subject FK Error
Author Sudheer Palaparambil
Hi,

What does the following error means ? This happened
when I tried to create a foreign key on table batch
(both tables are empty now )
ALTER TABLE batch ADD FOREIGN KEY (PRODUCT_ID)
REFERENCES PRODUCT(ID);

ERROR
-----------
Attempt to store duplicate value (visible to active
transactions) in unique index "RDB$INDEX_16"
Statement: ALTER TABLE BATCH ADD CONSTRAINT
"BATCH_TO_PRODUCT_ON_PRODUCT_ID" FOREIGN KEY
(PRODUCT_ID) REFERENCES PRODUCT (ID)


CREATE DOMAIN "PRODUCT_ID" AS DECIMAL(5, 0)
CHECK (VALUE > 0) NOT NULL;


CREATE TABLE "PRODUCT"
(
"ID" "PRODUCT_ID",
"IT_NAME" "NAME50" NOT NULL,
"PHARMA_ID" "ID4",
"CATG_ID" "ID4",
"RO_LEVEL" "QUANTITY",
"DN_LEVEL" "QUANTITY",
"RO_QTY" VARCHAR(25),
"INTRODUCED" DATE,
"SCHEME" "NAME30",
"TRIMMED_NM" "NAME50",
"STOCK" "QUANTITY",
"MFR" "MF_SHORT" NOT NULL,
PRIMARY KEY ("ID")
);


CREATE TABLE "BATCH"
(
"CONTROL_NO" "CONTROL_NO",
"PRODUCT_ID" "PRODUCT_ID",
"OPENING" "QUANTITY",
"CLOSING" "QUANTITY",
"MRP" "RATE",
"BATCH" "BATCH",
"EXPIRY" "EXP_DT",
"LIVE" CHAR(1) DEFAULT 'Y' NOT NULL,
"BATCH_OUT" DATE,
"FROZEN" CHAR(1) DEFAULT 'N' NOT NULL,
PRIMARY KEY ("CONTROL_NO")
);



Thank you

Sudheer

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page from News and Sport to Email and Music Charts
http://uk.my.yahoo.com