我在 MySQL 数据库上有一个存储过程,用于更新我的记录。根据输入,将小时数添加到列中,或将小时数减去列。我使用 Appian 智能服务将这个 SP 称为存储过程。我的问题是,如果尝试同时执行加减运算(针对不同的行),那么存储过程不会执行任何操作。它在我的流程模型中运行良好,但数据库未更新。如果我只使用一个输入(加法或减法)运行 PM,那么它会相应地更新数据库。谁能告诉我我在 SP 中做错了什么?注意:addAttendeeUsername 和 removeAttendeeUsername 输入都是用逗号分隔的 VARCHAR 字符串
BEGIN
DECLARE startTime datetime;
DECLARE SQLStateCode varchar(5) DEFAULT '00000';
DECLARE ErrorNumber int;
DECLARE MessageText varchar(1000);
-- insert / update
set @sql = concat("UPDATE
XCS_APP_CERTIFICATION
SET
COMPLETED_HOURS = COMPLETED_HOURS + ", courseHours , ",
LAST_MODIFIED_BY = '", lastModifiedBy, "',
LAST_MODIFIED_ON = NOW()
WHERE
XCS_APP_CERTIFICATION.CREATED_BY in (" , addAttendeeUsername , ") AND VALID_START_DATE <= '", offeringEndDateTime, "'
AND GRACE_PER_END_DATE >= '", offeringEndDateTime,"' ");
set @sql2 = concat("UPDATE
XCS_APP_CERTIFICATION
SET
COMPLETED_HOURS = COMPLETED_HOURS - ", courseHours, ",
LAST_MODIFIED_BY = '", lastModifiedBy, "',
LAST_MODIFIED_ON = NOW()
WHERE
CREATED_BY IN (", removeAttendeeUsername, ") AND VALID_START_DATE <= '", offeringEndDateTime, "'
AND GRACE_PER_END_DATE >= '", offeringEndDateTime, "' ");
PREPARE stmt FROM @sql;
EXECUTE stmt;
PREPARE stmt2 FROM @sql2;
EXECUTE stmt2;
set successFlag = 1;
-- committing transaction
COMMIT;
END