Subject Re: [firebird-support] doing cascade update manually?
Author Martijn Tonies
Hi David,


> create table t1 (id int not null primary key, i int, unique(i));
> create table t2 (id int not null primary key, i int references t1(i));
>
> insert into t1 values (1,1);
> insert into t1 values (2,2);
> insert into t2 values (1,1);
>
> t2(i) is not declared 'cascade update'. Can I update t1(i) like this
>
> update t1 set i=3 where id=1;
>
> as well as updating t2(i)? In other words, I want to do cascade
> manually/case-by-case in this situation (sometimes I want to forbid
> changes to a referenced unique column, and sometimes I want to allow
> that change and propagating the changes to all referencing columns as
well).

As you might have noticed, constraints are not deferred
until "commit" time. So if, while updating, you are violating
any constraints, the update will fail. So there's no way to
do this.

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com