而不是虚拟列的触发值

时间:2017-02-04 12:47:22

标签: sql oracle

我有从表格创建的视图:

CREATE OR REPLACE VIEW employee_list AS
    SELECT firstName || ' ' || lastName AS "employee"
    FROM employees;
END;

我想在此视图中插入值。我创建了INSTEAD OF触发器:

CREATE OR REPLACE TRIGGER trigger_v_emp_list
INSTEAD OF INSERT ON employee_list
FOR EACH ROW
BEGIN
    dbms_output.put_line(:new.employee);
END;

但是当我试图编译这个触发器时,我得到错误:

Error(3,24): PLS-00049: bad bind variable 'NEW.EMPLOYEE'

是否有可能在触发器中插入此值以将此值插入employees表中?当然,我会将这个值分成两个独立的值。

1 个答案:

答案 0 :(得分:1)

"employee"使其区分大小写。 当你写道:new.employee时,它试图寻找大写。别名也会发生同样的事情。应该让它发挥作用:

CREATE OR REPLACE VIEW employee_list AS
    SELECT firstName || ' ' || lastName AS employee
    FROM employees;
END;