аскадного видалення всіх товарів, що зберігаються на складі
CREATE TRIGGER "DEL_FROM_STORAGE" FOR "STORAGE" BEFORE DELETE POSITION 0from store where store_id = old.id;
end
Тригери для таблиці В«МістаВ»
Тригер для генерації первинного ключа
CREATE TRIGGER "GEN_ID_CITY" FOR "CITIES" BEFORE INSERT POSITION 0 (new.id is null) new.id = gen_id (id_city, 1); p>
Тригер для видалення всіх складів і постачальників з цього міста
CREATE TRIGGER "DEL_FROM_CITIES" FOR "CITIES" BEFORE DELETE POSITION 0from suppliers where city_id = old.id; from storeage where city_id = old.id;
end
Тригери для таблиці В«ЗаявкиВ»
Триггердлягенерациипервичногоключа
CREATE TRIGGER "GEN_ID_REQUEST" FOR "REQUESTS" BEFORE INSERT POSITION 0 begin (new.id is null) new.id = gen_id (id_request, 1);
end
Тригери для таблиці В«ЗберіганняВ»
Тріггернавставкувтабліцу
CREATE TRIGGER "STORE_INS" FOR "STORE" BEFORE INSERT POSITION 0variable my_id integer; variable my_good_id integer; variable amount integer; _id, good_id from store where store_id = new.store_id and good_id = new.good_id into my_id, my_good_id; (: my_id is not null) amount from store where store_id =: my_id and good_id =: my_good_id into: amount; (: amount + new.amount
end
Тригери для представлення В«Постачальник - ТоварВ»
Тригер на вставку
CREATE TRIGGER "INS_FOR_VIEW" FOR "SUPP_GOODS" BEFORE INSERT POSITION 0variable my_id integer; variable my_city_id integer; id from goods where new.good_name = name into my_id; (: my_id is null ) theninto goods (name, information) values ​​(new.good_name, new.information); id from goods where new.good_name = name into my_id; id from cities where new.city = name into my_city_id; (: my_city_id is null) theninto cities (name) values ​​(new.city); id from cities where new.city = name into my_city_id;
insert into suppliers (name, city_id, good_id) values ​​(new.supp_name,: my_city_id,: my_id);
Тригер на оновлення
CREATE TRIGGER "UPD_FOR_VIEW" FOR "SUPP_GOODS" BEFORE UPDATE POSITION 0variable my_id integer; variable my_city_id integer; variable my_supp_id integer; id from cities where name = new.city into my_city_id; ( : my_city_id is null) then exce...