oracle - 无法理解 ':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)
推荐阅读
- monogame - 在 MCGP 之后在 GLSL 中缺少声明
- apache-kafka - 如何设置 Kafka Streams 消息压缩?
- apache - 网站通过了 https ssl 认证,但端口不是?
- python - 如何在不发送自我的情况下从内部类更改外部类?
- java - 使用 hazelcast 客户端-服务器拓扑连接到数据库
- excel - 使用 Excel VBA 打开 SAS Enterprise Guide 7.1 egp 文件
- java - 添加时,选中的项目始终附加在数组列表中
- sql - 计算任何项目中不包含 X 的 Opps
- c - C 无 EOF 信号
- java - 使用 RxJava 执行并行任务并等待最后一个任务完成