下表:
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)
当有 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;