简体   繁体   English

Mac OSX MySQL更新存储过程

[英]Mac OSX MySQL Update Stored Procedure

Good afternoon, 下午好,

I am attempting to run a stored procedure that updates records in MySQL 5.1 on Mac OSX 10.4.11. 我试图运行一个存储过程,以更新Mac OSX 10.4.11上MySQL 5.1中的记录。 Here is a sample procedure: 这是一个示例过程:

DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `TestUpd`()
BEGIN

    UPDATE Addr
    SET eMail2 = 'test';

END
$$

When I execute this procedure, I get the error, 'Error executing SQL command'. 执行此过程时,出现错误“执行SQL命令时出错”。 I've tried various options, but this is the simplest example that illustrates the problem. 我尝试了各种选择,但这是说明问题的最简单示例。

This does not happen when I try the same thing in MySQL 5.1 on Windows XP. 当我在Windows XP上的MySQL 5.1中尝试相同的操作时,不会发生这种情况。

Any ideas? 有任何想法吗?

Thank you, 谢谢,

Igal 伊加尔

As a follow-up, we stumbled upon a workaround and will post it here for future reference. 作为后续,我们偶然发现了一种解决方法,并将其发布在此处以供将来参考。

When we added a select statement to the stored procedure after the UPDATE statement, the procedure worked as expected. 当我们在UPDATE语句之后向存储过程中添加一个select语句时,该过程按预期工作。 This is not an optimal workaround since you will not be able to modify your procedures in all cases, but we are able to do so in our case. 这不是一个最佳的解决方法,因为您将无法在所有情况下都修改程序,但是我们可以在这种情况下进行修改。 The following then worked for us: 然后,以下内容为我们工作:

DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `TestUpd`()
BEGIN

    UPDATE Addr
    SET eMail2 = 'test';

    SELECT 0;

END
$$

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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