我正在尝试创建一个过程,以便在修复错误时更新行。下面是它的样子:
DELIMITER $$
CREATE PROCEDURE bugFix (
IN rid_in INT,
IN fix_details_in VARCHAR (300)
) BEGIN
SET @resolved_qry = CONCAT('UPDATE _bug_report SET resolved = 1 WHERE rid = ', rid_in);
PREPARE stmt FROM @resolved_qry;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
UPDATE _bug_report SET fix_details = CONCAT(fix_details, fix_details_in) WHERE rid = CONCAT(rid, rid_in);
END $$
DELIMITER ;
将解析类型更改为1时:
SET @resolved_qry = CONCAT('UPDATE _bug_report SET resolved = 1 WHERE rid = ', rid_in);
PREPARE stmt FROM @resolved_qry;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
但是,在更新 fix_details
列以包含它不起作用的详细信息:
UPDATE _bug_report SET fix_details = CONCAT(fix_details, fix_details_in) WHERE rid = CONCAT(rid, rid_in);
我这样称呼它:
CALL bugFix(1, 'Hey, we fixed it');
你知道怎么用这个吗 fix_details_in
价值?
1条答案
按热度按时间cgvd09ve1#
为什么要使用动态sql?
想必,“不工作”就是这个意思
fix_details
未更新。那是因为没有匹配的:鉴于此
rid_in
如果是整数,则此操作将始终失败。