我将一些现有的存储过程从SQL Server移到MySQL 5.1.67。
我在我的存储过程中使用动态查询,有时(随机但经常)我在执行动态查询时遇到错误,然后进入Exit Handler。我已经打印了动态查询,并且能够单独执行它而没有任何问题。 如果我做错了什么,任何人都可以告诉我。
这是我构建的动态查询 -
SELECT T1.`R_Approved By1` AS `R_Approved By1`,
CAST(DATE_FORMAT(STR_TO_DATE(T1.`R_Approved Date1`,'%m/%d/%Y'),'%m/%d/%Y') AS CHAR) AS `R_Approved Date1`,
T1.`R_Status1` AS `R_Status1`,
T1.`R_Comments1` AS `R_Comments1`,
T1.`R_Approved By2` AS `R_Approved By2`,
CAST(DATE_FORMAT(STR_TO_DATE(T1.`R_Approved Date2`,'%m/%d/%Y'),'%m/%d/%Y') AS CHAR) AS `R_Approved Date2`,
T1.`R_Status2` AS `R_Status2`,
T1.`R_Comments2` AS `R_Comments2`,
T1.`R_Approved By3` AS `R_Approved By3`,
CAST(DATE_FORMAT(STR_TO_DATE(T1.`R_Approved Date3`,'%m/%d/%Y'),'%m/%d/%Y') AS CHAR) AS `R_Approved Date3`,
T1.`R_Status3` AS `R_Status3`,
T1.`R_Comments3` AS `R_Comments3`
FROM `GROUP_1` AS T1
WHERE T1.ID = 2;