简体   繁体   中英

MySQL Procedure With Multiple Updates

Does anyone know what's going wrong here? : - The following code works on my local server - executed using MySQL workbench: -

DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `namechange`(IN oldname VARCHAR(20),IN newname VARCHAR(20))
BEGIN
UPDATE liquidfinger.users SET username = newname WHERE username = oldname LIMIT 1;
UPDATE liquidfinger.markers SET username = newname WHERE username = oldname;
UPDATE liquidfinger.photos SET user = newname WHERE user = oldname;
UPDATE liquidfinger.mail SET to_name = newname WHERE to_name = oldname;
UPDATE liquidfinger.mail SET from_name = newname WHERE from_name = oldname;
END$$
DELIMITER ;

But I can't create the procedure on my website, hosted by GoDaddy and using phpMyAdmin. The error message I get back reads: -

"MySQL said: #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 'UPDATE liquidfinger.markers SET username = newname WHERE username = oldname; UP' at line 3"

The second update is always the point at which the problem begins - so that it doesn't like more than one update. The GoDaddy MySQL server version is: -Server version: 5.5.41-cll-lve - MySQL Community Server (GPL) The latest MySQL version is 5.6.25

Any ideas?

Thanks.

Okay, I've got it to work. I tried using the SQL tab in phpMyAdmin before and it didn't work, but I tried it again omitting "DEFINER= . ." and it worked. So I can only conclude there is some sort of bug in phpMyAdmin(?) But previously I have tried exporting and importing sql files using MySQL workbench - and that didn't work either(?) Case closed - I'm not sure if I should tick my own answer?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM