Hello there,I have written the following code for sqlite,I have also switched ON my foreign key and my previous foreign key references are also working , but in this code I am unable to figure out the error, the code is right but it's not accepting my values.
CREATE TABLE "customer_master" (
"cust_initial" CHAR(1) ,
"cust_slno" INTEGER(6) PRIMARY KEY NOT NULL ,
"cust_name" CHAR(40) ,
"cust_add1" CHAR(40) ,
"cust_add2" CHAR(40) ,
"cust_add3" CHAR(40) ,
"cust_pincode" CHAR(10) ,
"cust_city" CHAR(15) ,
"contact_person_name" CHAR(30) ,
"contact_person_number " CHAR(20) ,
"state_code" CHAR(2),
FOREIGN KEY (state_code) REFERENCES state_master (state_code));
INSERT INTO "customer_master" VALUES ("A","3","Arvind Kejriwall","5387-N","Kaushambi","Delhi","94830","Delhi","Nitish Kumar","9214809545","UP");
INSERT INTO "customer_master" VALUES ("A","931","Anuj","37-L","Vaishali","Delhi","56752","Delhi","Yadav","735657832","DL");
INSERT INTO "customer_master" VALUES ("L","29","Lakshay","5532/I","Andheri","Punjab","9545","Punjab","Mehta","2736252513","PJ");
CREATE TABLE "order_header" (
"order_no" INTEGER(8) PRIMARY KEY NOT NULL ,
"order_creation_date" DATETIME,
"order_status" CHAR(4),
"customer_ref_no" CHAR(40),
"customer_ref_date" DATETIME,
"order_value" INTEGER(11),
"material_required_date" DATETIME,
"customer_initial" CHAR(1),
"customer_slno" INTEGER(6),
"delivery_challan_no" INTEGER(8),
"shipment_date" DATETIME,
"invoice_number" INTEGER(8),
"invoice_date" DATETIME,
"transporter_name" CHAR(40),
"plant_code" CHAR(4),
"machine_installed_by" CHAR(40),
"cheque_no" CHAR(15),
"bank_name" CHAR(15),
FOREIGN KEY (customer_initial,customer_slno) REFERENCES customer_master (cust_initial,cust_slno),
FOREIGN KEY (plant_code) REFERENCES plant_master (plant_code));
When I try to INSERT any value in order_header , Sqlite always shows foreign key mismatch error for custumer_master. Pls help !!! :(
Aucun commentaire:
Enregistrer un commentaire