Toad World® Forums

Colon NEW

Did a search but couldn’t find anything that explains what “:NEW” does. Can anyone explain what this does. Code extract below…

INSERT INTO MOD_LOSS_MIT_LOAN_REVIEW(ROW_ID,OA)

Thanks in advance!
Mike

VALUES (:NEW.ROW_ID,:NEW.OA);

Message from: brian_leach_781

In a table trigger, by default :new.var refers to the new value going into the
row, :old.var refers to the old value. These will be the same if the value is
not being updated, or the function is an insert.

A common technique within a trigger is to not allow a value to change, as in:

if inserting then
:new.create_date := sysdate;
:new.create_user := sysuser;
else if updating then
:new.create_date := :old.create_date;
:new.create_user := :old.create_user;
end if;

:new.modified_date := sysdate;
:new.modified_user := sysuser;

I did this by memory, so forgive me if there are any mistakes.


Historical Messages

Author: brian_leach_781
Date: Tue May 03 15:36:21 PDT 2011
In a table trigger, by default :new.var refers to the new value going into the
row, :old.var refers to the old value. These will be the same if the value is
not being updated, or the function is an insert.

A common technique within a trigger is to not allow a value to change, as in:

if inserting then
:new.create_date := sysdate;
:new.create_user := sysuser;
else if updating then
:new.create_date := :old.create_date;
:new.create_user := :old.create_user;
end if;

:new.modified_date := sysdate;
:new.modified_user := sysuser;

I did this by memory, so forgive me if there are any mistakes.
__

Author: Mike Thomas
Date: Thu Apr 14 08:58:49 PDT 2011

Did a search but couldn’t find anything that explains what “:NEW”
does. Can anyone explain what this does. Code extract below…

INSERT INTO MOD_LOSS_MIT_LOAN_REVIEW ( ROW_ID , OA )

VALUES (:NEW. ROW_ID ,:NEW. OA );

Thanks in advance!
Mike

__


In a table trigger, by default :new.var refers to the new value going into the row, :old.var refers to the old value. These will be the same if the value is not being updated, or the function is an insert.

A common technique within a trigger is to not allow a value to change, as in:

if inserting then
:new.create_date := sysdate;
:new.create_user := sysuser;
else if updating then
:new.create_date := :old.create_date;
:new.create_user := :old.create_user;
end if;

:new.modified_date := sysdate;
:new.modified_user := sysuser;

I did this by memory, so forgive me if there are any mistakes.