需要知道绑定变量的解析

时间:2018-03-29 01:51:38

标签: sql oracle triggers

CREATE OR REPLACE TRIGGER transaction_type_af_insert
AFTER INSERT ON transaction_type
FOR EACH ROW
DECLARE
aatype VARCHAR2(30);
action VARCHAR2(30);
BEGIN
CASE 
 WHEN INSERTING THEN
 action  :=  'After_Insert_transaction_type';
END CASE;
INSERT INTO transaction_type_log_history (aatype,  action) VALUES  
(:new.aatype,  action);
END;
/
SHOW ERROR;

我得到以下错误:

LINE/COL|ERROR
9/69    |PLS-00049: bad bind variable 'NEW.AATYPE'

transaction_type表已经有一个'类型'列,因此代码已被修改,以将该值带入触发器的日志表中。更正了无错误编译的代码:

CREATE OR REPLACE TRIGGER transaction_type_af_insert
AFTER INSERT 
ON transaction_type
FOR EACH ROW
DECLARE
action VARCHAR2(30);
BEGIN
CASE 
WHEN INSERTING THEN
action := 'After_Insert_transaction_type';
END CASE;
INSERT INTO transaction_type_log_history (type, action)
VALUES (:new.type, action);
END;
/
SHOW ERROR;

0 个答案:

没有答案