我试图创建一个程序,它在一小时前工作,现在它抛出了一个错误。我导出了程序(为我复制了一个文本语句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说:文档
答案 0 :(得分:0)
在上一次删除查询中,您在变量名称之前缺少@
:
DELETE
FROM Cards
WHERE CardName = aName; -- should be @aName
另外,删除
DEFINER=`root`@`localhost`
如果您有任何意图远程访问您的数据库,请从您的程序。