嗨,我正试图使用此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$$
但我错了:
错误1241(21000):操作数应包含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工作台的SQL IDE,这些错误将被突出显示,并且更容易修复。