Guest User

Untitled

a guest
Dec 9th, 2019
130
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE OR REPLACE TRIGGER ДОКУМЕНТS_A_IUD_S AFTER DELETE OR INSERT OR UPDATE OF КОЛИЧЕСТВО_ДОКУМЕНТОВ, ЗАЯ_ЗАЯ_ID ON ДОКУМЕНТS
  2. DECLARE
  3. CURSOR ДОК IS SELECT DISTINCT ДОК_ID FROM ДОКУМЕНТS;КОЛИЧЕСТВО NUMBER(4);
  4. BEGIN
  5. FOR CUR_БОЛ IN ДОК LOOP
  6. SELECT SUM(ЧИСЛО_КОЕК) INTO КОЛИЧЕСТВО FROM ДОКУМЕНТS WHERE ДОКУМЕНТS.ЗАЯ_ЗАЯ_ID = CUR_БОЛ.ЗАЯ_ID;
  7. UPDATE ЗАЯВЛЕНИЕS SET КОЛИЧЕСТВО_ДОКУМЕНТОВ = КОЛИЧЕСТВО WHERE ЗАЯВЛЕНИЕS.ЗАЯ_ID = CUR_БОЛ.ЗАЯ_ID;
  8. END LOOP;
  9. DELETE ДОКУМЕНТS;
  10. END;
RAW Paste Data