oracle new 和old 关键字

今天在看书,有一个触发器的例子,

create or replace trigger aaaa
before insert
on bbbb
begin
insert into cccc values (new.name,new.num);
end;

创建一个触发器 aaaa,当向bbbb插入数据时,都要在cccc里插入相同的数据,但是写好程序后 运行时会报错,

对照着书上的例子 并没有发现什么不一样,

然后百度了一下new的用法,更改后

create or replace trigger aaaa
before insert 
on bbbb
for each row
begin
insert into cccc values (:new.name,:new.num);
end;

就可以正常运行了。

用法:

添加:for each row 指定为行触发器

:new 新的数据

:old 旧数据

insert 语句有new 

delete语句有old

update 两个都有

猜你喜欢

转载自www.cnblogs.com/winterbear/p/10311970.html
今日推荐