daily pastebin goal
71%
SHARE
TWEET

trigger

a guest Jun 14th, 2018 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. DELIMITER //
  3. DROP TRIGGER IF EXISTS my_insert_trigger//
  4. CREATE DEFINER=root@localhost TRIGGER my_insert_trigger
  5.     AFTER INSERT ON `promene`
  6.     FOR EACH ROW
  7.  
  8. BEGIN
  9.     CALL set_aktivan_procedura(pid);
  10. END//
  11. DELIMITER ;
  12.  
  13.  
  14. DELIMITER //
  15. DROP TRIGGER IF EXISTS my_update_trigger//
  16.  
  17. CREATE DEFINER=root@localhost TRIGGER my_update_trigger
  18.     AFTER UPDATE ON `promene`
  19.     FOR EACH ROW
  20. BEGIN
  21.     -- Call the common procedure ran if there is an INSERT or UPDATE on `promene`
  22.     CALL set_aktivan_procedura(pid);
  23. END//
  24. DELIMITER ;
  25.  
  26.  
  27. DELIMITER //
  28. DROP PROCEDURE IF EXISTS set_aktivan_procedura//
  29.  
  30. CREATE DEFINER=root@localhost PROCEDURE set_aktivan_procedura( out aktivan tinyint)
  31. READS SQL DATA
  32. BEGIN
  33. case  
  34. when pdo IS NOT NULL then      
  35. set `aktivan` = 1;
  36.  
  37. when pdo IS NULL  then
  38. set `aktivan` = 0;
  39.  
  40.  
  41. end case;  
  42.     -- Write your MySQL code to perform when a `promene` row is inserted or updated here
  43.  
  44. END//
  45. DELIMITER ;
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