I am moving to a webserver from my local client which used mysql 5.5 the web server has mySQL 5.0.91 and i’m having trouble moving over the stored procedures that worked fine on my localhost.
For instance.
CREATE PROCEDURE `add_student`(IN section_id VARCHAR(20), IN student_id VARCHAR(20))
BEGIN
DECLARE EXIT HANDLER FOR 1062
INSERT INTO error_log(status_id,Student_ID, Section_ID, status_message,time_now)
VALUES('1062',student_id, section_id,' You are already enrolled for this Course, buddy! ', NOW());
DECLARE EXIT HANDLER FOR 1364
INSERT INTO error_log(status_id,Student_ID, Section_ID, status_message,time_now)
VALUES('1364',student_id, section_id,' ???? ', NOW());
SET @section_id=section_id;
SET @student_id=student_id;
PREPARE STMT FROM
"INSERT INTO course(SECTION_ID,STUDENT_ID ) VALUES(?,?)";
PREPARE STMT2 FROM
"INSERT INTO transcript(SECTION_ID,STUDENT_ID) VALUES(?,?)";
EXECUTE STMT USING @section_id,@student_id;
EXECUTE STMT2 USING @section_id,@student_id;
END
worked fine in mysql 5.5 but now it give me the follow error: #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 6. Is there anyway around this or do I need to look for hosting that uses the same version of MYSQL that my localhost has?
How are you trying to load this procedure? If you had this exact text in a .sql file and were doing something like
mysql < procedure.sqlIt would certainly return an error like this.You need to change the statement delimiter, so mysql doesn’t get confused — right now I’m betting it thinks that the first ; ends the statement.
before the procedure do:
DELIMITER \\and the last line should be:
END\\