微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法理解':new'的工作方式

如何解决无法理解':new'的工作方式

if (false = FALSE) then  

    :NEW.last_modified := sysdate;
:new.ssn := null;

解决方法

我们通常在行级触发器中使用:OLD引用旧值,并使用:NEW引用新值。

:OLD:NEW的值在数据操作语言语句中可能会有所不同。

将数据插入表中时

 :OLD = NULL (since no old record)  
 :NEW = Newly inserted value

更新表中的数据时

 :OLD = Value exists in the table before the UPDATE statement executes 
 :NEW = Newly received value to replace the existing value of the record

从表中删除数据时

 :OLD = Value exists in the table before the DELETE statement executes 
 :NEW = NULL

例如,假设您要以 Alex ;

的形式将新记录插入表 Employee 中。
 :OLD = NULL (since no old record)  
 :NEW = Alex

现在,您要将值 Alex 更新为 John

 :OLD = Alex
 :NEW = John

删除此记录时,

 :OLD = John
 :NEW = NULL (since the record has been deleted)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。