SHARE
TWEET

Untitled

a guest Jun 25th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. TRIGER 1
  2. I ==>
  3.  
  4. CREATE OR REPLACE TRIGGER "Pitanja_update"
  5. AFTER
  6. UPDATE OF broj_poena ON Pitanja
  7. FOR EACH ROW
  8. DECLARE
  9. novi_broj_poena NUMBER(3);
  10. novi_id NUMBER(3);
  11. PRAGMA AUTONOMOUS_TRANSACTION;
  12. BEGIN
  13. EXECUTE IMMEDIATE 'ALTER TRIGGER "Odgovori_UPDATE_broj_poena" DISABLE';
  14. novi_broj_poena := :new.broj_poena;
  15. novi_id := :new.id;
  16. UPDATE Odgovori
  17. SET broj_poena = novi_broj_poena
  18. WHERE id_pitanja = novi_id;
  19. EXECUTE IMMEDIATE 'ALTER TRIGGER "Odgovori_UPDATE_broj_poena" ENABLE';
  20. END;
  21.  
  22.  
  23. II ==>
  24.  
  25. CREATE OR REPLACE TRIGGER "Odgovori_UPDATE_broj_poena"
  26. BEFORE
  27. UPDATE OF broj_poena ON Odgovori
  28. FOR EACH ROW
  29. BEGIN
  30. RAISE_APPLICATION_ERROR(-20002, 'Broj poena se ne moze direktno menjati');
  31. END;
  32.  
  33.  
  34. III ==>
  35.  
  36. CREATE OR REPLACE TRIGGER "Odgovori_INSERT"
  37. BEFORE
  38. INSERT ON Odgovori
  39. FOR EACH ROW
  40. DECLARE
  41. broj_poena_pitanja NUMBER(3);
  42. BEGIN
  43. SELECT broj_poena INTO broj_poena_pitanja
  44. FROM Pitanja
  45. WHERE id = :new.id_pitanja;
  46. :new.broj_poena := broj_poena_pitanja;
  47. END;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top