PLSQL :NEW and :OLD

前端 未结 13 1165
孤街浪徒
孤街浪徒 2020-12-24 06:30

Can anyone help me understand when to use :NEW and :OLD in PLSQL blocks, I\'m finding it very difficult to understand their usage.

13条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-24 07:10

    A simple example that shows the use of old and new using triggers
    
    CREATE TABLE emp_log(
    emp_id NUMBER;
    updated_by DATE,
    new_salary VARCHAR2(15),
    Action VARCHAR2(20));
    
    CREATE OR REPLACE TRIGGER log_sal 
    AFTER UPDATE OF sal on emp
    FOR EACH ROW
    BEGIN
    INSERT INTO emp_log( emp_id, updated_by, new_salary, Action)
    VALUES(:NEW.empno, USER, :NEW.sal, 'New salary');
    END;
    /
    

提交回复
热议问题