Output new and old value in a before update trigger : Old New Value « Trigger « Oracle PL / SQL






Output new and old value in a before update trigger

    
SQL>
SQL> create table t ( x int, y int );

Table created.

SQL>
SQL> insert into t values ( 1, 1 );

1 row created.

SQL>
SQL> create or replace trigger t_bufer
  2  before update on t for each row
  3  begin
  4          dbms_output.put_line( 'old.x = ' || :old.x ||', old.y = ' || :old.y );
  5          dbms_output.put_line( 'new.x = ' || :new.x ||', new.y = ' || :new.y );
  6  end;
  7  /

Trigger created.

SQL> set serveroutput on
SQL> update t set x = x+1;
old.x = 1, old.y = 1
new.x = 2, new.y = 1

1 row updated.

SQL>
SQL> drop table t;

Table dropped.

SQL>

   
    
    
    
  








Related examples in the same category

1.Reference old and new value by column in a before update Trigger
2.This trigger uses predicates to log changes to the myStudent table.
3.These triggers demonstrate the use of the :new correlation identifier.
4.Create a trigger with 'REFERENCING new AS'
5.:old and :new Pseudo-records
6.If updating and new value equals old value
7.if ( updating or deleting ), if ( inserting or updating )