SQL> create table t( x int,
2 constraint t_pk primary key(x)
3 );
Table created.
SQL>
SQL>
SQL> create trigger t_trigger AFTER update on T for each row
2 begin
3 dbms_output.put_line( 'Updated x=' || :old.x || ' to x=' || :new.x );
4 end;
5 /
Trigger created.
SQL>
SQL> insert into t values ( 1 );
1 row created.
SQL> insert into t values ( 2 );
1 row created.
SQL>
SQL> set serveroutput on
SQL>
SQL> update t set x = 2;
Updated x=1 to x=2
Updated x=2 to x=2
update t set x = 2
*
ERROR at line 1:
ORA-00001: unique constraint (JAVA2S.T_PK) violated
SQL>
SQL> update t set x = x+1;
Updated x=1 to x=2
Updated x=2 to x=3
2 rows updated.
SQL>
SQL>
SQL> drop table t;
Table dropped.
SQL>
SQL>
SQL>
|