Triggerst - Triggers

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Triggers Triggers are PL/SQL procedures stored in the database.  It’s executed automatically  when a certain event occurs.  Let’s create a trigger to print an old and new grade every time when the grade in  dbst651_students is updated. create or replace trigger  Print_grade_change after update  on DBST651_students for each row BEGIN          dbms_output.put ('The grade was changed from ' ||  :old.grade );          dbms_output.put_line (' to ' ||   :new.grade ); END; / Use  create or replace trigger  statement and a single slash ( / ) at the last line.   Print_grade_change is a trigger name. After update  means that the trigger is fired after the data has been updated.  DBST651_students is the name of the table. For each row  statement is necessary because an update statement might be changing  the value in multiple rows. Like in any PL/SQL code, the trigger body needs to start with 
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

Triggerst - Triggers

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online