基本上,每当学生注册/放弃课程时,我都会运行此程序。我正在尝试在课程中设置 student_total = # of students,然后用 (student_total + 1) 更新相应的部分,我无法为存储过程找到好的文档。我的Declare student_total int;
线路出现错误。我做错了什么?
DELIMITER $$
CREATE PROCEDURE `mydb`.`update_seats` (IN section_ID varchar(20))
BEGIN
SET @section_id=section_id;
DECLARE student_total int;
-- count the number of students in the course --
SET student_total = SELECT count(student_ID) from course
WHERE section_ID = @section_id;
Update Section SET students_enrolled = (student_total + 1)
WHERE section_ID = @section_id;
END