create or replace TRIGGER SET_HOLDER_IN_ONLINE_DOC
BEFORE INSERT ON tasks
FOR EACH ROW
DECLARE
id, repl_id NUMBER;
BEGIN
IF :new.holder_role_id = 10 THEN
SELECT user_id, repl_user_id INTO id, repl_id FROM roles
WHERE roles.id=10;
IF repl_id = 0 THEN
:new.holder_user_id := id;
ELSE
WHILE repl_id > 0
LOOP
SELECT user_id, repl_user_id INTO id, repl_id FROM roles
WHERE user_id=repl_id;
END LOOP;
:new.holder_user_id := id;
END IF;
END IF;
END;
user2390701
问问题
197 次