您好我试图使用此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):操作数应包含1列
知道如何解决这个问题吗?
答案 0 :(得分:1)
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,则会突出显示这些错误,并且更容易修复。