Twoja aktualna logika uruchamia sam wyzwalacz przy każdej INSERT w nim!
Być może więc szukasz INSTEAD OF
wyzwalać za pomocą VIEW
create or replace TRIGGER trg_INSERTKEYWORDS
INSTEAD OF INSERT ON Keyword
To tak, jakby zamiast rzeczywistej wstawki na widoku zrobić to, co powiem w mojej logice wyzwalania!
Widok:
CREATE VIEW MYVIEW AS
SELECT
LISTAGG(keyword,',') WITHIN GROUP (ORDER BY seq) as keyword,
some_code
FROM Keyword
GROUP BY some_code;
Wyzwalacz:
create or replace TRIGGER trg_INSERTKEYWORDS
INSTEAD OF INSERT ON MYVIEW
FOR EACH ROW
DECLARE
varKeyWordsStr VARCHAR2 (255) := 'Hello,How,are,you,keeping';
/* Isn't it keyWord from the inserted value ?? */
BEGIN
FOR k IN (SELECT REGEXP_SUBSTR (varKeyWordsStr,'[^,]+',1,LEVEL) keyWord
FROM DUAL
CONNECT BY REGEXP_SUBSTR (varKeyWordsStr,'[^,]+',1,LEVEL)IS NOT NULL)
LOOP
INSERT INTO KEYWORD VALUES(seqKeyWord.NEXTVAL,k.keyWord,1000);
END LOOP;
END;