Обсуждение: What is the best way of writing update rule on view with joined tables?

Поиск
Список
Период
Сортировка

What is the best way of writing update rule on view with joined tables?

От
cpng@sophos.com (Cornelius Grotjahn)
Дата:
Please, how can I rewrite the rule below so that it works as intended for this
update:
  update v set ad=0, bd=0 where ad=1;

As it is now, this will change ad but not bd, presumably because when the
rule's first action has updated ad, the "where ad=1" returns 0 rows for the
second action.

I want this because that is the way MS Access puts data into updates' where
clauses and I want updateable forms on joined tables.

  create table a (k integer primary key, ad integer);  create table b (k integer primary key, bd integer);  create view
vas select a.k, ad, bd from a join b on a.k=b.k;  create rule r as on update to v do instead  (     update a set
ad=new.adwhere k=old.k;     update b set bd=new.bd where k=old.k;  );
 
  insert into a values(1,1);  insert into a values(2,2);  insert into b values(1,1);  insert into b values(2,2);


Thank you -- Cornelius