gpt4 book ai didi

MySQL SP : ERROR 1241 (21000)

转载 作者:行者123 更新时间:2023-11-29 03:01:47 31 4
gpt4 key购买 nike

您好,我正在尝试使用此 sp 插入语句插入:

call insertuser (1, '077788899965', 'Digest 1.0', ':=', 'asjdfhiuoadshgiadufg');

SP 代码:

DELIMITER$$

CREATE PROCEDURE insertuser (IN IdParam INT, IN UserNameParam varchar(64), IN AttributeParam varchar(64), IN OpParam char(2), IN ValueParam varchar(253))
BEGIN

// Delete user if they already exist

DELETE FROM radcheck
WHERE username = UserNameParam;

// Insert

INSERT INTO radcheck (id, username, atrribute, op, value)
SELECT (IdParam, UserNameParam, AttributeParam, OpParam, ValueParam);

END$$

但是我得到的错误是:

ERROR 1241 (21000): Operand should contain 1 column(s)

知道如何解决这个问题吗?

最佳答案

DELIMITER $$

CREATE PROCEDURE insertuser (IN IdParam INT, IN UserNameParam varchar(64),
IN AttributeParam varchar(64), IN OpParam char(2),
IN ValueParam varchar(253))
BEGIN
DELETE FROM radcheck
WHERE username = UserNameParam;

INSERT INTO radcheck (id, username, atrribute, op, `value`)
SELECT IdParam, UserNameParam, AttributeParam, OpParam, ValueParam;
END
$$

有两个问题:

  • DELIMITER 后缺少空格
  • // 在 MySQL 中不是注释开头。使用 /* */

如果您使用像 MySQL Workbench 这样的 SQL IDE,这样的错误将被突出显示并且更容易修复。

关于MySQL SP : ERROR 1241 (21000),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22480639/

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