P. 1
Apostila Completa Oracle 9i

Apostila Completa Oracle 9i

4.0

|Views: 3,585|Likes:
Published by Willian

More info:

Published by: Willian on Jul 22, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

11/30/2012

pdf

text

original

Um mesmo trigger pode ser disparado para INSERT, UPDATE e DELETE. Dentro
de um trigger desse tipo há três funções booleanas que podem ser usadas para determinar
qual é a operação que está disparando o trigger.

Exemplo:

CREATE OR REPLACE TRIGGER LogRSChanges
BEFORE INSERT OR DELETE OR UPDATE ON registered_students
FOR EACH ROW
DECLARE

v_ChangeType CHAR(1);

146

BEGIN

IF INSERTING THEN
v_ChangeType := 'I';
ELSIF UPDATING THEN
v_ChangeType := 'U';

ELSE

v_ChangeType := 'D';

END IF;

INSERT INTO RS_audit
(change_type, changed_by, timestamp,
old_student_id, old_department, old_course, old_grade,
new_student_id, new_department, new_course, new_grade)

VALUES

(v_ChangeType, USER, SYSDATE,
:old.student_id, :old.department, :old.course,

:old.grade,

:new.student_id, :new.department, :new.course,

:new.grade);
END LogRSChanges;
/

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->