Thread: on update, how to change the value?
Hi.
If I have table A (x integer primary key);
and table B (y integer references A on delete cascade );
and that a new item (x=70) gets inserted into A and a lot of items go into B that references the new item in A.
Now, if I really have to do:
delete from A where x=5;
update A set x=5 where x=70;
is there a way to make all the items in B change from 70 to 5 automatically (it must be done automatically since B can be a lot more than a signle table)?
There is an "on update" option to the create table command, but I can't find out if that will help me. The docs are unfortunatly a little short on describing the "on update" option.
Will "on update cascade" propagate the update to the B table?
If I have table A (x integer primary key);
and table B (y integer references A on delete cascade );
and that a new item (x=70) gets inserted into A and a lot of items go into B that references the new item in A.
Now, if I really have to do:
delete from A where x=5;
update A set x=5 where x=70;
is there a way to make all the items in B change from 70 to 5 automatically (it must be done automatically since B can be a lot more than a signle table)?
There is an "on update" option to the create table command, but I can't find out if that will help me. The docs are unfortunatly a little short on describing the "on update" option.
Will "on update cascade" propagate the update to the B table?
A B wrote: > Hi. > If I have table A (x integer primary key); > and table B (y integer references A on delete cascade ); > There is an "on update" option to the create table command, but I can't > find out if that will help me. The docs are unfortunatly a little short on > describing the "on update" option. > > Will "on update cascade" propagate the update to the B table? Yes. -- Richard Huxton Archonet Ltd