无法理解':new'的工作
Unable to understand the working for ':new'
if (false = FALSE) then
:NEW.last_modified := sysdate;
:new.ssn := null;
我们通常使用 :OLD
引用旧值,使用 :NEW
引用行级触发器中的新值。
:OLD
和 :NEW
的值在数据操作语言语句中可能会有所不同。
向table插入数据时
:OLD = NULL (since no old record)
:NEW = Newly inserted value
更新 table
中的数据时
:OLD = Value exists in the table before the UPDATE statement executes
:NEW = Newly received value to replace the existing value of the record
从 table
中删除数据时
:OLD = Value exists in the table before the DELETE statement executes
:NEW = NULL
例如,假设您要在 table Employee 中插入一条新记录作为 Alex;
:OLD = NULL (since no old record)
:NEW = Alex
现在您要将值 Alex 更新为 John
:OLD = Alex
:NEW = John
当您删除这条记录时,
:OLD = John
:NEW = NULL (since the record has been deleted)
if (false = FALSE) then
:NEW.last_modified := sysdate;
:new.ssn := null;
我们通常使用 :OLD
引用旧值,使用 :NEW
引用行级触发器中的新值。
:OLD
和 :NEW
的值在数据操作语言语句中可能会有所不同。
向table插入数据时
:OLD = NULL (since no old record)
:NEW = Newly inserted value
更新 table
中的数据时 :OLD = Value exists in the table before the UPDATE statement executes
:NEW = Newly received value to replace the existing value of the record
从 table
中删除数据时 :OLD = Value exists in the table before the DELETE statement executes
:NEW = NULL
例如,假设您要在 table Employee 中插入一条新记录作为 Alex;
:OLD = NULL (since no old record)
:NEW = Alex
现在您要将值 Alex 更新为 John
:OLD = Alex
:NEW = John
当您删除这条记录时,
:OLD = John
:NEW = NULL (since the record has been deleted)