Student table : student ID, student name, student contact
Evaluation: EvalID, Eval number
学生从1-7开始评估每节课。我需要创建一个复制学生信息的触发器,如果他们评估7,他们会给另一个表格进行评估
我所做的是
Create or replace trigger test
After Insert on evaluation
when (eval_number = 0)
Begin
我不知道该怎么办......任何想法?并且我的第一个触发器是正确的吗?
答案 0 :(得分:3)
下表:
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;