Your problem is that your foreign key is not referencing the entire primary key from HEAD
.
So you either need to change the foreign key (to include name in there) or change the primary key of HEAD
to exclude name there.
So either change
CONSTRAINT pk_head PRIMARY KEY (Code, Name));
to
CONSTRAINT pk_head PRIMARY KEY (Code));
or change
CONSTRAINT fk_subhead FOREIGN KEY (HCode) REFERENCES HEAD(Code)
to
CONSTRAINT fk_subhead FOREIGN KEY (HCode, Name) REFERENCES HEAD(Code, Name)