为表student_course,当向表student_course插入数据时,如果成绩大于等于60分,该学生就能得到相应的学分,否则该学生不能得到相应的学分
知道答案了!
CREATE TRIGGER sc_tri ON student_course
FOR INSERT
AS
update student_course
set credit =
case
when sc.grade=60 then
(select c.credit
from course c
where sc.course_id=c.course_id)
end
from student_course sc,inserted i
where sc.student_id=i.student_id and sc.course_id=i.course_id