gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
H) Link instructor to course on specific slot i. Type: Stored Procedure ii. Name:…
- User
H) Link instructor to course on specific slot i. Type: Stored Procedure ii. Name: Procedures_AdminLinkInstructor iii. Input: InstructorId int, courseId int, and slotID int iv. Output: Nothing
- Assistant
CREATE PROCEDURE Procedures_AdminLinkInstructor @InstructorId int, @CourseId int, @SlotId int AS BEGIN -- Check if the provided InstructorId, CourseId, and SlotId exist IF NOT EXISTS (SELECT 1 FROM Instructors WHERE InstructorId = @InstructorId) BEGIN RAISERROR('InstructorId does not exist', 16, 1) RETURN END
codeIF NOT EXISTS (SELECT 1 FROM Courses WHERE CourseId = @CourseId) BEGIN RAISERROR('CourseId does not exist', 16, 1) RETURN END IF NOT EXISTS (SELECT 1 FROM Slots WHERE SlotId = @SlotId) BEGIN RAISERROR('SlotId does not exist', 16, 1) RETURN END -- Check if the Instructor is already linked to the Course in the specified Slot IF EXISTS (SELECT 1 FROM CourseSlotInstructor WHERE InstructorId = @InstructorId AND CourseId = @CourseId AND SlotId = @SlotId) BEGIN RAISERROR('Instructor is already linked to the Course in the specified Slot', 16, 1) RETURN END -- Link the Instructor to the Course in the specified Slot INSERT INTO CourseSlotInstructor (InstructorId, CourseId, SlotId) VALUES (@InstructorId, @CourseId, @SlotId)