从phpMyAdmin上的存储过程复制文本后,无法执行sql statment来创建过程

时间:2016-04-23 07:29:19

标签: mysql stored-procedures phpmyadmin

我试图创建一个程序,它在一小时前工作,现在它抛出了一个错误。我导出了程序(为我复制了一个文本语句phpmyadmin输出),它不会让我执行我导出的代码。导出的代码如下,然后是phpmyadmin显示的错误报告。

此外,所有sql查询都可以自行运行,但是在我导出过程之前调用该过程时,它正在运行,但查询不会影响任何行。我是否将变量标记为错误或其他什么?(我不认为我是,我确实检查过)

我输入的内容:

CREATE DEFINER=`root`@`localhost` PROCEDURE `DeleteCard`(IN `@aName` VARCHAR(255))
NO SQL
BEGIN
UPDATE Decks 
JOIN Amount ON amount.DeckName = decks.DeckName 
SET decks.DeckTotal = Decks.DeckTotal - Decks.DeckTotal
WHERE Amount.AmountName = @aName;

UPDATE Types t1
JOIN Cards ON cards.TypeName = t1.TypeName 
JOIN Amount ON amount.CardName = Cards.CardName
SET t1.TypeTotal = t1.TypeTotal - Amount.Amount
WHERE Amount.CardName = @aName;

DELETE  
FROM Amount 
WHERE CardName = @aName;


DELETE  
FROM Cards 
WHERE CardName = aName;
END

错误报告:

CREATE DEFINER=`root`@`localhost` PROCEDURE `DeleteCard`(IN `aName` VARCHAR(255))
NO SQL
BEGIN
UPDATE Decks 
JOIN Amount ON amount.DeckName = decks.DeckName 
SET decks.DeckTotal = Decks.DeckTotal - Decks.DeckTotal
WHERE Amount.AmountName = aName;

MySQL说:文档

1064 - 您的SQL语法出错;查看与您的MySQL服务器版本相对应的手册,以获得在''附近使用的正确语法。在第7行

1 个答案:

答案 0 :(得分:0)

在上一次删除查询中,您在变量名称之前缺少@

DELETE  
FROM Cards 
WHERE CardName = aName; -- should be @aName

另外,删除

DEFINER=`root`@`localhost`
如果您有任何意图远程访问您的数据库,请从您的程序