daily pastebin goal
38%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DROP TRIGGER IF EXISTS check_parent_path_when_update;
  2. DROP TRIGGER IF EXISTS check_parent_path_when_insert;
  3. delimiter //
  4. CREATE TRIGGER check_parent_path_when_update  BEFORE UPDATE
  5. on identifier
  6. FOR EACH ROW
  7. BEGIN
  8. DECLARE idCount INT;
  9. DECLARE canUpdate boolean default false;
  10.  IF @disable_trigger IS NULL THEN
  11.    select count(id)into idCount from identifier where asset_type='folder' and CONCAT(parent_path,asset_name,'/')= NEW.parent_path and host_inode = NEW.host_inode and id <> NEW.id;
  12.    IF(idCount > 0 OR NEW.parent_path = '/' OR NEW.parent_path = '/System folder') THEN
  13.      SET canUpdate := TRUE;
  14.    END IF;
  15.    IF(canUpdate = FALSE) THEN
  16.      delete from Cannot_update_for_this_path_does_not_exist_for_the_given_host;
  17.    END IF;
  18.  END IF;
  19. END
  20. //
  21. CREATE TRIGGER check_parent_path_when_insert  BEFORE INSERT
  22. on identifier
  23. FOR EACH ROW
  24. BEGIN
  25. DECLARE idCount INT;
  26. DECLARE canInsert boolean default false;
  27.  select count(id)into idCount from identifier where asset_type='folder' and CONCAT(parent_path,asset_name,'/')= NEW.parent_path and host_inode = NEW.host_inode and id <> NEW.id;
  28.  IF(idCount > 0 OR NEW.parent_path = '/' OR NEW.parent_path = '/System folder') THEN
  29.    SET canInsert := TRUE;
  30.  END IF;
  31.  IF(canInsert = FALSE) THEN
  32.   delete from Cannot_insert_for_this_path_does_not_exist_for_the_given_host;
  33.  END IF;
  34. END
  35. //
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