Following tables:
CREATE TABLE student(
studentId INTEGER,
student_name varchar2(100),
student_contact varchar2(100));
CREATE TABLE evaluation(
evalId INTEGER,
eval_num INTEGER,
student_id INTEGER)
create table eval_audit(
studentId INTEGER,
student_name VARCHAR2(100),
student_contact VARCHAR2(100),
eval_num INTEGER)
Trigger to insert data from student when there is a evaluation with 7:
CREATE OR REPLACE TRIGGER AIEvaludation
AFTER INSERT ON evaluation
FOR EACH ROW
WHEN (new.eval_num = 7)
DECLARE
CURSOR curStudent IS
SELECT studentid, student_name, student_contact
FROM student
WHERE studentid = :new.student_id;
--
vRowStudent curStudent%ROWTYPE;
BEGIN
OPEN curStudent;
FETCH curStudent INTO vRowStudent;
CLOSE curStudent;
INSERT INTO eval_audit
(studentid, student_name, student_contact, eval_num)
VALUES (vRowStudent.studentid, vRowStudent.student_name, vRowStudent.student_contact, :new.eval_num);
END AIEvaludation;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…