2 gto
Some DDL code:
Code: Select all
CREATE TABLE IF NOT EXISTS plots
(
CadNom CHAR(19) NOT NULL UNIQUE,
Area DECIMAL(10,4) NOT NULL,
Perimeter DECIMAL(10,4) NOT NULL,
LandCategory TINYINT UNSIGNED NOT NULL,
TargetUsing VARCHAR(8) NOT NULL,
Status TINYINT UNSIGNED,
PRIMARY KEY(CadNom),
FOREIGN KEY(LandCategory) REFERENCES kz_codes(Id),
FOREIGN KEY(TargetUsing) REFERENCES cv_codes(Id),
FOREIGN KEY(Status) REFERENCES statuses(Id)
) ENGINE=InnoDB;
CREATE TABLE IF NOT EXISTS lands
(
Id BIGINT UNSIGNED AUTO_INCREMENT,
CadNom CHAR(19) NOT NULL,
Area DECIMAL(10,4) NOT NULL,
Perimeter DECIMAL(10,4) NOT NULL,
LandType CHAR(4) NOT NULL,
Status TINYINT UNSIGNED,
PRIMARY KEY(Id),
FOREIGN KEY(CadNom) REFERENCES plots(CadNom),
FOREIGN KEY(LandType) REFERENCES cn_codes(Id),
FOREIGN KEY(Status) REFERENCES statuses(Id)
) ENGINE=InnoDB;
Error occurs, for example, when inserting record to lands table with LandType value than don't satisfy constraint check. Also for error generation i'm using simple UDF that raises error (
see here).
2 designshouse
Thanks, i'm try your code today