Кажется, вы добавляете неправильное имя столбца в :NEW.new_skill_desc
, в :new.
вы должны указать столбец для таблицы LDS_SKILL
таблицы, а не db_lds_skill
Ниже я создал локально, и он работал нормально. Обратите внимание, что я заменил to_date
на to_char
и заменил M0N
на MON
drop table db_lds_skill
/
create table db_lds_skill
(new_skill_desc varchar2(100) null,
old_skill_desc varchar2(100) null,
user_name varchar2(100) null,
entry_date varchar2(100),
operation varchar2(100) null
)
/
drop table LDS_SKILL
/
create table LDS_SKILL
(new_skill_desc varchar2(100) null,
old_skill_desc varchar2(100) null,
user_name varchar2(100) null,
entry_date varchar2(100) nulll,
operation varchar2(100) null
)
/
CREATE OR REPLACE TRIGGER lds_skill_trig
BEFORE INSERT OR DELETE OR UPDATE ON LDS_SKILL
FOR EACH ROW
ENABLE
DECLARE
v_user VARCHAR2(30);
v_date VARCHAR2(30);
BEGIN
SELECT user, TO_CHAR(sysdate, 'DD/MON/YYYY HH24:MI:SS')
INTO v_user, v_date FROM dual;
IF INSERTING THEN
INSERT INTO db_lds_skill(new_skill_desc, old_skill_desc,user_name,
entry_date, operation)
VALUES(:NEW.new_skill_desc, NULL, v_user, v_date, 'Insert');
ELSIF DELETING THEN
INSERT INTO db_lds_skill(new_skill_desc, old_skill_desc, user_name,
entry_date, operation)
VALUES(NULL, :OLD.new_skill_desc, v_user, v_date, 'Delete');
ELSIF UPDATING THEN
INSERT INTO db_lds_skill(new_skill_desc, old_skill_desc, user_name,
entry_date, operation)
VALUES(:NEW.new_skill_desc, :OLD.new_skill_desc, v_user, v_date,'update');
END IF;
END;
/
insert into LDS_SKILL (new_skill_desc) values('pp')
/
commit
/