gpt4 book ai didi

mysql - 为什么此过程会引发 'Unknown Column' 错误

转载 作者:行者123 更新时间:2023-11-29 14:23:16 24 4
gpt4 key购买 nike

我有这个过程,但这会引发“未知列”错误

USE dhod;
DELIMETER @@
CREATE PROCEDURE sp_drive_size(IN uname VARCHAR(100),IN size INT)
BEGIN
DECLARE dsize INT DEFAULT 0;
DECLARE new_size INT DEFAULT 0;
SELECT drive_size INTO dsize FROM profile WHERE username = uname;
SET new_size=dsize+size;
UPDATE profile SET drive_size=new_size WHERE username = uname;
END @@
DELIMETER ;

我收到此错误“where 子句”中存在未知列“uname”

最佳答案

这是您的原始代码

USE dhod;
DELIMETER @@
CREATE PROCEDURE sp_drive_size(IN uname VARCHAR(100),IN size INT)
BEGIN
DECLARE dsize INT DEFAULT 0;
DECLARE new_size INT DEFAULT 0;
SELECT drive_size INTO dsize FROM profile WHERE username = uname;
SET new_size=dsize+size;
UPDATE profile SET drive_size=new_size WHERE username = uname;
END @@
DELIMETER ;

你相信你拼错了 DELIMETER 吗???

应该是DELIMITER(我会将其更改为$$)

USE dhod;
DELIMITER $$
CREATE PROCEDURE sp_drive_size(IN uname VARCHAR(100),IN size INT)
BEGIN
DECLARE dsize INT DEFAULT 0;
DECLARE new_size INT DEFAULT 0;
SELECT drive_size INTO dsize FROM profile WHERE username = uname;
SET new_size=dsize+size;
UPDATE profile SET drive_size=new_size WHERE username = uname;
END $$
DELIMITER ;

关于mysql - 为什么此过程会引发 'Unknown Column' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11420443/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com