Quantcast
Channel: MySQL Forums - InnoDB
Viewing all articles
Browse latest Browse all 1956

Cascade update fails on MySQL for foreign keys referring to the same table (1 reply)

$
0
0
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.

Viewing all articles
Browse latest Browse all 1956

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>