CREATE DEFINER = 'root'@'localhost' PROCEDURE `GetClassScheduleConflicts`(
IN TermID INTEGER,
IN SectionID VARCHAR(45),
IN sDay VARCHAR(10),
IN TimeStart VARCHAR(10),
IN TimeEnd VARCHAR(10)
)
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
SELECT CS.SubjectOfferingID, CS.TermID, CS.SubjectID, S.SubjectCode, S.SubjectTitle, S.CreditUnits,
CS.SectionID, CSec.SectionName,
CS.Sched1, fnRoomName2(RoomID) AS Room_1,
CS.Sched2, fnRoomName2(RoomID2) AS Room_2,
CS.Sched3, fnRoomName2(RoomID3) AS Room_3,
CS.Sched4, fnRoomName2(RoomID4) AS Room_4,
CS.Sched5, fnRoomName2(RoomID4) AS Room_5,
CS.Days1,CS.Days2,CS.Days3,CS.Days4,CS.Days5,
fnCollegeCode(CSec.CollegeID) AS CollegeCode,
fnProgramCode(CSec.ProgramID) AS ProgramCode
FROM tblClassSchedule AS CS LEFT JOIN
tblSubject AS S ON S.SubjectID = CS.SubjectID LEFT JOIN
tblSection AS CSec ON CSec.SectionID = CS.SectionID
WHERE (CS.TermID = TermID) AND (CS.SectionID = SectionID)
AND (
( (CS.Days1 LIKE sDay) AND ((CS.SchedTimeStart BETWEEN TimeStart AND TimeEnd) OR (CS.SchedTimeEnd BETWEEN TimeStart AND TimeEnd) OR ((CS.SchedTimeEnd > TimeStart AND CS.SchedTimeEnd
AND ((CS.SchedTimeEnd > TimeStart AND CS.SchedTimeEnd
)
OR
( (CS.Days2 LIKE sDay) AND ((CS.SchedTimeStart2 BETWEEN TimeStart AND TimeEnd) OR (CS.SchedTimeEnd2 BETWEEN TimeStart AND TimeEnd) OR ((CS.Time2_End > TimeStart AND CS.SchedTimeEnd2
AND ((CS.SchedTimeEnd2 > TimeStart AND CS.Time2_End
)
OR
( (CS.Days3 LIKE sDay) AND ((CS.SchedTimeStart3 BETWEEN TimeStart AND TimeEnd) OR (CS.SchedTimeEnd3 BETWEEN TimeStart AND TimeEnd) OR ((CS.Time3_End > TimeStart AND CS.SchedTimeEnd3
AND ((CS.SchedTimeEnd3 > TimeStart AND CS.SchedTimeEnd3
)
OR
( (CS.Days4 LIKE sDay) AND ((CS.SchedTimeStart4 BETWEEN TimeStart AND TimeEnd) OR (CS.SchedTimeEnd4 BETWEEN TimeStart AND TimeEnd) OR ((CS.Time4_End > TimeStart AND CS.SchedTimeEnd4
AND ((CS.SchedTimeEnd4 > TimeStart AND CS.SchedTimeEnd4
)
OR
( (CS.Days5 LIKE sDay) AND ((CS.SchedTimeStart5 BETWEEN TimeStart AND TimeEnd) OR (CS.SchedTimeEnd5 BETWEEN TimeStart AND TimeEnd) OR ((CS.Time5_End > @TimeStart AND CS.SchedTimeEnd5
AND ((CS.SchedTimeEnd5 > TimeStart AND CS.SchedTimeEnd5
)
);
END;
CREATE DEFINER = 'root'@'localhost' PROCEDURE `GetFacultyScheduleConflicts`(
TermID INT,
FacultyID VARCHAR(15),
sDay VARCHAR(10),
TimeStart VARCHAR(10),
TimeEnd VARCHAR(10)
)
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
SELECT SubjectOfferingID, CS.TermID, CS.SubjectID, S.SubjectCode, S.SubjectTitle, S.CreditUnits, CSec.SectionTitle,
CS.Sched1, fnRoomName2(CS.RoomID) AS Room_1,
CS.Sched2, fnRoomName2(CS.RoomID2) AS Room_2,
CS.Sched3, fnRoomName2(CS.RoomID3) AS Room_3,
CS.Sched4, fnRoomName2(CS.RoomID4) AS Room_4,
CS.Sched5, fnRoomName2(CS.RoomID5) AS Room_5,
fnProgramCode(CSec.ProgramID) AS ProgramCode
FROM tblClassSchedule AS CS LEFT JOIN
tblSubject AS S ON S.SubjectID = CS.SubjectID LEFT JOIN
tblSection AS CSec ON CSec.SectionID = CS.SectionID
WHERE (CS.TermID = TermID) AND
(CS.TeacherID = FacultyID) AND
(CS.Days LIKE sDay) AND
((SchedTimeStart BETWEEN TimeStart AND TimeEnd) OR (SchedTimeEnd BETWEEN TimeStart AND TimeEnd)
OR ((SchedTimeEnd > TimeStart AND SchedTimeEnd
AND ((SchedTimeEnd > TimeStart AND SchedTimeEnd
/*----------------------------------*/
UNION -- SCHEDULE.1 TO SCHEDULE.2
/*----------------------------------*/
SELECT SubjectOfferingID, CS.TermID, CS.SubjectID, S.SubjectCode, S.SubjectTitle, S.CreditUnits, CSec.SectionTitle,
CS.Sched1, fnRoomName2(CS.RoomID) AS Room_1,
CS.Sched2, fnRoomName2(CS.RoomID2) AS Room_2,
CS.Sched3, fnRoomName2(CS.RoomID3) AS Room_3,
CS.Sched4, fnRoomName2(CS.RoomID4) AS Room_4,
CS.Sched5, fnRoomName2(CS.RoomID5) AS Room_5,
fnProgramCode(CSec.ProgramID) AS ProgramCode
FROM tblClassSchedule AS CS LEFT JOIN
tblSubject AS S ON S.SubjectID = CS.SubjectID LEFT JOIN
tblSection AS CSec ON CSec.SectionID = CS.SectionID
WHERE (CS.TermID = TermID) AND
(CS.TeacherID2 = FacultyID) AND
(Days2 LIKE sDay) AND
((SchedTimeStart2 BETWEEN TimeStart AND TimeEnd) OR (SchedTimeEnd2 BETWEEN TimeStart AND TimeEnd)
OR ((SchedTimeEnd2 > TimeStart AND SchedTimeEnd2
AND ((SchedTimeEnd2 > TimeStart AND SchedTimeEnd2
/*----------------------------------*/
UNION -- SCHEDULE.2 TO SCHEDULE.3
/*----------------------------------*/
SELECT SubjectOfferingID, CS.TermID, CS.SubjectID, S.SubjectCode, S.SubjectTitle, S.CreditUnits, CSec.SectionTitle,
CS.Sched1, fnRoomName2(CS.RoomID) AS Room_1,
CS.Sched2, fnRoomName2(CS.RoomID2) AS Room_2,
CS.Sched3, fnRoomName2(CS.RoomID3) AS Room_3,
CS.Sched4, fnRoomName2(CS.RoomID4) AS Room_4,
CS.Sched5, fnRoomName2(CS.RoomID5) AS Room_5,
fnProgramCode(CSec.ProgramID) AS ProgramCode
FROM tblClassSchedule AS CS LEFT JOIN
tblSubject AS S ON S.SubjectID = CS.SubjectID LEFT JOIN
tblSection AS CSec ON CSec.SectionID = CS.SectionID
WHERE (CS.TermID = TermID) AND
(CS.TeacherID3 = FacultyID) AND
(Days3 LIKE sDay) AND
((SchedTimeStart3 BETWEEN TimeStart AND TimeEnd) OR (SchedTimeEnd3 BETWEEN TimeStart AND TimeEnd)
OR ((SchedTimeEnd3 > TimeStart AND SchedTimeEnd3
AND ((SchedTimeEnd3 > TimeStart AND SchedTimeEnd3
/*----------------------------------*/
UNION -- SCHEDULE.3 TO SCHEDULE.4
/*----------------------------------*/
SELECT SubjectOfferingID, CS.TermID, CS.SubjectID, S.SubjectCode, S.SubjectTitle, S.CreditUnits, CSec.SectionTitle,
CS.Sched1, fnRoomName2(CS.RoomID) AS Room_1,
CS.Sched2, fnRoomName2(CS.RoomID2) AS Room_2,
CS.Sched3, fnRoomName2(CS.RoomID3) AS Room_3,
CS.Sched4, fnRoomName2(CS.RoomID4) AS Room_4,
CS.Sched5, fnRoomName2(CS.RoomID5) AS Room_5,
fnProgramCode(CSec.ProgramID) AS ProgramCode
FROM tblClassSchedule AS CS LEFT JOIN
tblSubject AS S ON S.SubjectID = CS.SubjectID LEFT JOIN
tblSection AS CSec ON CSec.SectionID = CS.SectionID
WHERE (CS.TermID = TermID) AND
(CS.TeacherID4 = FacultyID) AND
(Days4 LIKE sDay) AND
((SchedTimeStart4 BETWEEN TimeStart AND TimeEnd) OR (SchedTimeEnd4 BETWEEN TimeStart AND TimeEnd)
OR ((SchedTimeEnd4 > TimeStart AND SchedTimeEnd4
AND ((SchedTimeEnd4 > TimeStart AND SchedTimeEnd4
/*----------------------------------*/
UNION -- SCHEDULE.4 TO SCHEDULE.5
/*----------------------------------*/
SELECT SubjectOfferingID, CS.TermID, CS.SubjectID, S.SubjectCode, S.SubjectTitle, S.CreditUnits, CSec.SectionTitle,
CS.Sched1, fnRoomName2(CS.RoomID) AS Room_1,
CS.Sched2, fnRoomName2(CS.RoomID2) AS Room_2,
CS.Sched3, fnRoomName2(CS.RoomID3) AS Room_3,
CS.Sched4, fnRoomName2(CS.RoomID4) AS Room_4,
CS.Sched5, fnRoomName2(CS.RoomID5) AS Room_5,
fnProgramCode(CSec.ProgramID) AS ProgramCode
FROM tblClassSchedule AS CS LEFT JOIN
tblSubject AS S ON S.SubjectID = CS.SubjectID LEFT JOIN
tblSection AS CSec ON CSec.SectionID = CS.SectionID
WHERE (CS.TermID = TermID) AND
(CS.TeacherID5 = FacultyID) AND
(Days5 LIKE sDay) AND
((SchedTimeStart5 BETWEEN TimeStart AND TimeEnd) OR (SchedTimeEnd5 BETWEEN TimeStart AND TimeEnd)
OR ((SchedTimeEnd5 > TimeStart AND SchedTimeEnd5
AND ((SchedTimeEnd5 > TimeStart AND SchedTimeEnd5
END;
CREATE DEFINER = 'root'@'localhost' PROCEDURE `GetRoomScheduleConflicts`(
TermID INT,
RoomID VARCHAR(15),
sDay VARCHAR(10),
TimeStart VARCHAR(10),
TimeEnd VARCHAR(10)
)
DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
SELECT SubjectOfferingID, CS.TermID, CS.SubjectID, S.SubjectCode, S.SubjectTitle, S.CreditUnits, CSec.SectionTitle,
CS.Sched1, fnRoomName2(CS.RoomID) AS Room_1,
CS.Sched2, fnRoomName2(CS.RoomID2) AS Room_2,
CS.Sched3, fnRoomName2(CS.RoomID3) AS Room_3,
CS.Sched4, fnRoomName2(CS.RoomID4) AS Room_4,
CS.Sched5, fnRoomName2(CS.RoomID5) AS Room_5,
fnProgramCode(CSec.ProgramID) AS ProgramCode
FROM tblClassSchedule AS CS LEFT JOIN
tblSubject AS S ON S.SubjectID = CS.SubjectID LEFT JOIN
tblSection AS CSec ON CSec.SectionID = CS.SectionID
WHERE (CS.TermID = TermID) AND
(CS.RoomID = RoomID) AND
(CS.Days LIKE sDay) AND
((SchedTimeStart BETWEEN TimeStart AND TimeEnd) OR (SchedTimeEnd BETWEEN TimeStart AND TimeEnd)
OR ((SchedTimeEnd > TimeStart AND SchedTimeEnd
AND ((SchedTimeEnd > TimeStart AND SchedTimeEnd
/*----------------------------------*/
UNION -- SCHEDULE.1 TO SCHEDULE.2
/*----------------------------------*/
SELECT SubjectOfferingID, CS.TermID, CS.SubjectID, S.SubjectCode, S.SubjectTitle, S.CreditUnits, CSec.SectionTitle,
CS.Sched1, fnRoomName2(CS.RoomID) AS Room_1,
CS.Sched2, fnRoomName2(CS.RoomID2) AS Room_2,
CS.Sched3, fnRoomName2(CS.RoomID3) AS Room_3,
CS.Sched4, fnRoomName2(CS.RoomID4) AS Room_4,
CS.Sched5, fnRoomName2(CS.RoomID5) AS Room_5,
fnProgramCode(CSec.ProgramID) AS ProgramCode
FROM tblClassSchedule AS CS LEFT JOIN
tblSubject AS S ON S.SubjectID = CS.SubjectID LEFT JOIN
tblSection AS CSec ON CSec.SectionID = CS.SectionID
WHERE (CS.TermID = TermID) AND
(CS.RoomID2 = RoomID) AND
(Days2 LIKE sDay) AND
((SchedTimeStart2 BETWEEN TimeStart AND TimeEnd) OR (SchedTimeEnd2 BETWEEN TimeStart AND TimeEnd)
OR ((SchedTimeEnd2 > TimeStart AND SchedTimeEnd2
AND ((SchedTimeEnd2 > TimeStart AND SchedTimeEnd2
/*----------------------------------*/
UNION -- SCHEDULE.2 TO SCHEDULE.3
/*----------------------------------*/
SELECT SubjectOfferingID, CS.TermID, CS.SubjectID, S.SubjectCode, S.SubjectTitle, S.CreditUnits, CSec.SectionTitle,
CS.Sched1, fnRoomName2(CS.RoomID) AS Room_1,
CS.Sched2, fnRoomName2(CS.RoomID2) AS Room_2,
CS.Sched3, fnRoomName2(CS.RoomID3) AS Room_3,
CS.Sched4, fnRoomName2(CS.RoomID4) AS Room_4,
CS.Sched5, fnRoomName2(CS.RoomID5) AS Room_5,
fnProgramCode(CSec.ProgramID) AS ProgramCode
FROM tblClassSchedule AS CS LEFT JOIN
tblSubject AS S ON S.SubjectID = CS.SubjectID LEFT JOIN
tblSection AS CSec ON CSec.SectionID = CS.SectionID
WHERE (CS.TermID = TermID) AND
(CS.RoomID3 = RoomID) AND
(Days3 LIKE sDay) AND
((SchedTimeStart3 BETWEEN TimeStart AND TimeEnd) OR (SchedTimeEnd3 BETWEEN TimeStart AND TimeEnd)
OR ((SchedTimeEnd3 > TimeStart AND SchedTimeEnd3
AND ((SchedTimeEnd3 > TimeStart AND SchedTimeEnd3
/*----------------------------------*/
UNION -- SCHEDULE.3 TO SCHEDULE.4
/*----------------------------------*/
SELECT SubjectOfferingID, CS.TermID, CS.SubjectID, S.SubjectCode, S.SubjectTitle, S.CreditUnits, CSec.SectionTitle,
CS.Sched1, fnRoomName2(CS.RoomID) AS Room_1,
CS.Sched2, fnRoomName2(CS.RoomID2) AS Room_2,
CS.Sched3, fnRoomName2(CS.RoomID3) AS Room_3,
CS.Sched4, fnRoomName2(CS.RoomID4) AS Room_4,
CS.Sched5, fnRoomName2(CS.RoomID5) AS Room_5,
fnProgramCode(CSec.ProgramID) AS ProgramCode
FROM tblClassSchedule AS CS LEFT JOIN
tblSubject AS S ON S.SubjectID = CS.SubjectID LEFT JOIN
tblSection AS CSec ON CSec.SectionID = CS.SectionID
WHERE (CS.TermID = TermID) AND
(CS.RoomID4 = RoomID) AND
(Days4 LIKE sDay) AND
((SchedTimeStart4 BETWEEN TimeStart AND TimeEnd) OR (SchedTimeEnd4 BETWEEN TimeStart AND TimeEnd)
OR ((SchedTimeEnd4 > TimeStart AND SchedTimeEnd4
AND ((SchedTimeEnd4 > TimeStart AND SchedTimeEnd4
/*----------------------------------*/
UNION -- SCHEDULE.4 TO SCHEDULE.5
/*----------------------------------*/
SELECT SubjectOfferingID, CS.TermID, CS.SubjectID, S.SubjectCode, S.SubjectTitle, S.CreditUnits, CSec.SectionTitle,
CS.Sched1, fnRoomName2(CS.RoomID) AS Room_1,
CS.Sched2, fnRoomName2(CS.RoomID2) AS Room_2,
CS.Sched3, fnRoomName2(CS.RoomID3) AS Room_3,
CS.Sched4, fnRoomName2(CS.RoomID4) AS Room_4,
CS.Sched5, fnRoomName2(CS.RoomID5) AS Room_5,
fnProgramCode(CSec.ProgramID) AS ProgramCode
FROM tblClassSchedule AS CS LEFT JOIN
tblSubject AS S ON S.SubjectID = CS.SubjectID LEFT JOIN
tblSection AS CSec ON CSec.SectionID = CS.SectionID
WHERE (CS.TermID = TermID) AND
(CS.RoomID5 = RoomID) AND
(Days5 LIKE sDay) AND
((SchedTimeStart5 BETWEEN TimeStart AND TimeEnd) OR (SchedTimeEnd5 BETWEEN TimeStart AND TimeEnd)
OR ((SchedTimeEnd5 > TimeStart AND SchedTimeEnd5
AND ((SchedTimeEnd5 > TimeStart AND SchedTimeEnd5
END;
/*=================== STORED FUNCTION ===========================*/
CREATE DEFINER = 'root'@'localhost' FUNCTION `fnProgramName`( ProgID INT )
RETURNS VARCHAR(100) CHARSET utf8
DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
DECLARE ProgramName VARCHAR(100);
SELECT Programs.ProgName INTO ProgramName FROM tblPrograms AS Programs WHERE Programs.ProgID = ProgID
LIMIT 1;
RETURN ifnull(ProgramName,'');
END;
CREATE DEFINER = 'root'@'localhost' FUNCTION `fnRoomName2`(
sRoomID VARCHAR(45)
)
RETURNS VARCHAR(60) CHARSET utf8
DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
DECLARE RoomName VARCHAR(60);
SELECT CONCAT(fnBuildingAcronym(R.BldgID) , '-' , R.Room) INTO RoomName FROM tblRoom AS R
WHERE R.RoomID = sRoomID LIMIT 1;
RETURN RoomName;
END;