Skip navigation links

MySQL Forums :: InnoDB :: Cascade update fails on MySQL for foreign keys referring to the same table


Advanced Search

Cascade update fails on MySQL for foreign keys referring to the same table
Posted by: andrea esposito ()
Date: December 08, 2012 06:05AM

Hi all,
I have this table:
create table if not exists Treni(
id varchar(10),
tipo enum('R','ICN','ES','IC','EX','RV','ESAV','ESC','EN') not null,
partenza varchar(50) not null,
arrivo varchar(50) not null,
direzione varchar(50) not null,
provenienza varchar(50) default null,
destinazione varchar(50),
orarioPartenza time not null,
orarioArrivo time not null,
id_sconto int(9) not null,
constraint `fk1` foreign key(partenza) references Stazioni(citta) on delete cascade on update cascade,
constraint `fk2` foreign key(arrivo) references Stazioni(citta) on delete cascade on update cascade,
constraint `fk3` foreign key(provenienza) references Stazioni(citta) on delete cascade on update cascade,
constraint `fk4` foreign key(destinazione) references Stazioni(citta) on delete cascade on update cascade,
constraint `fk5` foreign key(sconto) references Percentuali(percentuale) on delete restrict on update cascade,
primary key(id,partenza,arrivo,orarioPartenza)
);

when i do this:
update Stazioni set citta='Cas' where citta='Caserta';
I have an error,fk3 fails.I have found this:
Deviation from SQL standards: If ON UPDATE CASCADE or ON UPDATE SET NULL recurses to update the same table it has previously updated during the cascade, it acts like RESTRICT
Is there any work around?Mysql version is 5.5.8.Thank you.

Options: ReplyQuote


Subject Views Written By Posted
Cascade update fails on MySQL for foreign keys referring to the same table 1181 andrea esposito 12/08/2012 06:05AM
Re: Cascade update fails on MySQL for foreign keys referring to the same table 412 Barry Galbraith 12/08/2012 07:21PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.