What is the correct way to pass values into this Stored procedure, obviously I’m not doing it the right way, and is it safe to execute two statements in one procedure or should I make two separate ones?
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `drop_student`(IN section_id VARCHAR(20), IN student_id VARCHAR(20))
BEGIN
SET @section_id=section_id;
SET @student_id=student_id;
PREPARE STMT2 FROM
"DELETE FROM transcript
WHERE STUDENT_ID = @student_id
AND SECTION_ID = @section_id ";
PREPARE STMT FROM
"DELETE FROM course
WHERE STUDENT_ID = @student_id
AND SECTION_ID = @section_id ";
EXECUTE STMT2 USING @section_id,@student_id;
EXECUTE STMT USING @section_id,@student_id;
END
Are you sure you are using
SQL Server(I seesql servertag) in your code above? I guess it’sMySQL. Do it like thisSQL Syntax for Prepared Statements