| Variables [message #647663] |
Thu, 04 February 2016 16:49  |
 |
M123
Messages: 47 Registered: February 2016 Location: USA
|
Member |

|
|
Hi all
what are these variables new. and old ,are they automatically processed.
please check this link below
http://www.tutorialspoint.com/plsql/plsql_triggers.htm
OLD and NEW references are not available for table level triggers, rather you can use them for record level triggers. does plsql engine process new. and old. automatically ?
same here in below namedblock, i mentioned new. , does plsql internally considers it as new variable ?
create or replace trigger crazy_trigge1r before update
on employees
for each row
begin
if :new.last_name = 'Pataballa' then
:new.salary := :new.salary * 0.1;
dbms_output.put_line('update done for the last name '||:new.last_name);
end if;
end;
Please help in understanding this basic functionality ,what does that "new." do ,any comments
[EDITED by LF: fixed topic title typo and applied code tags]
[Updated on: Fri, 05 February 2016 00:05] by Moderator Report message to a moderator
|
|
|
|
|
|
| Re: varaibles [message #647667 is a reply to message #647663] |
Thu, 04 February 2016 18:18   |
 |
M123
Messages: 47 Registered: February 2016 Location: USA
|
Member |

|
|
CREATE OR replace TRIGGER crazy_trigge1r
BEFORE UPDATE ON employees
FOR EACH ROW
BEGIN
IF :new.last_name = 'Pataballa' THEN
:new.salary := :new.salary * 0.1;
dbms_output.Put_line('update done for the last name '
||:new.last_name);
END IF;
END;
i have gone through this link https://docs.oracle.com/cd/B10501_01/appdev.920/a96590/adg13trg.htm#431Because the trigger uses the BEFORE keyword, it can access the new values before they go into the table, and can change the values if there is an easily-corrected error by assigning to :NEW.column_name
so does it mean this block can automatically declares new varialbe "new." and update it ? can you suggest what does this :new. do ?
[Updated on: Thu, 04 February 2016 18:33] Report message to a moderator
|
|
|
|
|
|
|
|