Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DROP TRIGGER IF EXISTS check_parent_path_when_update;
- DROP TRIGGER IF EXISTS check_parent_path_when_insert;
- delimiter //
- CREATE TRIGGER check_parent_path_when_update BEFORE UPDATE
- on identifier
- FOR EACH ROW
- BEGIN
- DECLARE idCount INT;
- DECLARE canUpdate boolean default false;
- IF @disable_trigger IS NULL THEN
- 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;
- IF(idCount > 0 OR NEW.parent_path = '/' OR NEW.parent_path = '/System folder') THEN
- SET canUpdate := TRUE;
- END IF;
- IF(canUpdate = FALSE) THEN
- delete from Cannot_update_for_this_path_does_not_exist_for_the_given_host;
- END IF;
- END IF;
- END
- //
- CREATE TRIGGER check_parent_path_when_insert BEFORE INSERT
- on identifier
- FOR EACH ROW
- BEGIN
- DECLARE idCount INT;
- DECLARE canInsert boolean default false;
- 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;
- IF(idCount > 0 OR NEW.parent_path = '/' OR NEW.parent_path = '/System folder') THEN
- SET canInsert := TRUE;
- END IF;
- IF(canInsert = FALSE) THEN
- delete from Cannot_insert_for_this_path_does_not_exist_for_the_given_host;
- END IF;
- END
- //
Add Comment
Please, Sign In to add comment