oracle 某列 触发后修改其他列,

使用before触发器,赋值采用   :new.需赋值字段  :=  值





SQL code

    Connected to Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 Connected as scott SQL> desc aa Name Type Nullable Default Comments ---- ------------ -------- ------- --------
ID1 NUMBER(10) Y
X VARCHAR2(10) Y
M VARCHAR2(10) Y
SQL>
SQL> create or replace trigger tri_aa
2 before update of x on aa
3 for each row
4 declare
5 begin
6 :new.m:=:new.x;
7 end;
8 / Trigger created
SQL> select * from aa where x='a'; ID1 X M ----------- ---------- ----------
1 a ттт 1 a test
SQL> update aa set x=x where x='a';
2 rows updated
SQL> select * from aa where x='a'; ID1 X M ----------- ---------- ---------- 1 a a 1 a a SQL>

猜你喜欢

转载自yhq1212.iteye.com/blog/1397776