Skip to content
Snippets Groups Projects
Commit bd91501b authored by PavelBegunkov's avatar PavelBegunkov
Browse files

fix: attaching student to group in CreateStudent

parent eece3288
Branches
Tags
No related merge requests found
......@@ -668,7 +668,7 @@ CREATE FUNCTION `CreateStudent`
) RETURNS int(11)
NO SQL
BEGIN
DECLARE vAccountID, vGroupID, vStudentID INT DEFAULT -1;
DECLARE vAccountID, vGroupID, vStudentID, vSemesterID INT DEFAULT -1;
DECLARE EXIT HANDLER FOR SQLEXCEPTION RETURN -1;
# find group
......@@ -693,10 +693,16 @@ BEGIN
(AccountID, LastName, FirstName, SecondName)
VALUES (vAccountID, pLastName, pFirstName, pSecondName);
SELECT general_settings.Val INTO vSemesterID
FROM `general_settings`
WHERE general_settings.Name = 'SemesterID'
LIMIT 1;
# bind group in current semester
INSERT INTO `students_groups`
(StudentID, GroupID, SemesterID)
VALUES (LAST_INSERT_ID(), vGroupID, @CurrentSemesterID);
VALUES (LAST_INSERT_ID(), vGroupID, vSemesterID);
RETURN 0;
END //
......@@ -767,24 +773,7 @@ BEGIN
SET vGroupID = LAST_INSERT_ID();
END IF;
# TODO: user roles
# create account
INSERT INTO `accounts`
(Login, Password , EMail, UserRoleID, ActivationCode )
VALUES ( NULL, NULL, NULL, 1, pActivationCode);
SET vAccountID = LAST_INSERT_ID();
# create student
INSERT INTO `students`
(AccountID, LastName, FirstName, SecondName)
VALUES (vAccountID, pLastName, pFirstName, pSecondName);
# bind group in current semester
INSERT INTO `students_groups`
(StudentID, GroupID, SemesterID)
VALUES (LAST_INSERT_ID(), vGroupID, @CurrentSemesterID);
RETURN ROW_COUNT()-1;
RETURN CreateStudent(pLastName, pFirstName, pSecondName, vGradeID, pGroupNum, pFacultyID, pActivationCode);
END //
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment