带连接的 ORACLE 触发器

ORACLE TRIGGER WITH JOIN

我想创建类似审计的东西table。

并且我想向此 table 插入来自 table CLIENT 的新值,并将此新值与来自 table CODEWORD 的值相结合。我尝试在插入到我的 table 客户端时使用触发器:

TRIGGER CLIENT_CODEWORD_INSERT
AFTER 
    INSERT ON TEST2.CLIENT 
    FOR EACH ROW
DECLARE code_word varchar2(100);
BEGIN
    SELECT t2.VAL INTO code_word FROM test2.CODEWORD t2 LEFT JOIN test2.CLIENT t1 ON T2.CLIENTID = t1.ID WHERE t1.Id = :NEW.ID;
    INSERT INTO CLIENT_UPDATE (
    ID
    ,NAME
    ,PHONE
    ,CODEWORD
    )
    VALUES (
    :NEW.ID
    ,SUBSTR (:NEW.NAME, 2,7)
    ,CONCat(:NEW.PHONE,'!')
    , code_word
    );
END;

但是我在尝试将值插入 table 客户端时收到错误消息:

SQL Error [4091] [42000]: ORA-04091: table TEST2.CLIENT is mutating, , trigger/function may not see it
ORA-06512: on "TEST2.CLIENT_CODEWORD_INSERT", line 3

无需加入SELECT语句;只需使用 :new.id.

CREATE OR REPLACE TRIGGER client_codeword_insert
   AFTER INSERT
   ON test2.client
   FOR EACH ROW
DECLARE
   code_word  VARCHAR2 (100);
BEGIN
   SELECT t2.val
     INTO code_word
     FROM test2.codeword t2
    WHERE t2.clientid = :new.id;

   INSERT INTO client_update (id,
                              name,
                              phone,
                              codeword)
        VALUES (:new.id,
                SUBSTR (:new.name, 2, 7),
                CONCAT (:new.phone, '!'),
                code_word);
END;