I was trying to use store procedure to update a mark result in the mark table. It was fine when running the script but it changed nothing. Does anyone know what I wrote wrong in the script?
Here is some information about the tables:
Student - Contains SID and CourseID
Course - CourseID and DeptID
Department - DeptID
Modules - ModuleID and DeptID
Mark - ModuleID, SID and MarkID
Here is my code:
Drop procedure if exists coursework.UpdateStudentMark;
DELIMITER //
Create procedure coursework.UpdateStudentMark
(
IN Message varchar(500) ,
IN StudentID text,
IN Academic_Year int,
IN Module_Code_And_Title text,
IN Module_Mark int
)
BEGIN
insert into logging_table (AuditText, timestamp )
values ( Message, now() );
update coursework.mark as mark
INNER JOIN
coursework.Modules USING (ModuleID)
INNER JOIN
coursework.department USING (DeptID)
INNER JOIN
coursework.course USING (DeptID)
INNER JOIN
coursework.student USING (CourseID , SID)
set
Module_Mark = mark.Module_Mark
Where student.StudentID = StudentID AND student.Academic_Year= Academic_Year AND Modules.Module_Code_And_Title = Module_Code_And_Title;
END;
//
Delimiter ;
I called the stored procedure by this code:
Call coursework.UpdateStudentMark ('Update Student Stats' ,'B3984673', 2018, 'EEEE3001: Third Year Project [FY]' , 1);
Um... correct me if I'm wrong, but you're just updating a column to be itself (setting mark.Module_Mark
= mark.Module_Mark
) e.g.,
update coursework.mark as mark
<...>
set
Module_Mark = mark.Module_Mark