I'm making a procedure for a school project that removes a specific course from the course table if it's not in use.
According to everything I've read this is the correct setup but tere's an error on that last "END;" line that says there's a "missing 'if'"
Delimiter //
CREATE PROCEDURE DeleteCourse
(
pCourseNumber varchar (7)
)
BEGIN
if NOT EXISTS(SELECT * FROM trackcourses WHERE courseNumber = pCourseNumber)
then
BEGIN
DELETE
FROM courses
WHERE courseNumber = pCourseNumber;
DELETE
FROM restrictors
WHERE courseNumber = pCourseNumber;
select row_count();
END;
else
BEGIN
return 'Course could not be deleted';
END;
END; // <-- Syntax error: missing 'if'
Any thoughts and ideas are greatly appreciated!
Thanks,
Weird.
ifin SQL. Quel SQL?TSQL, you've taggedtsqlandsql-server, but then mentioned that you're usingMySQLin a comment below. Please edit your question to clarify what you're using.