我正在尝试将一个存储过程从SQL Server迁移到MySQL。在转换try catch块时遇到了一些问题。我知道DECLARE HANDLER
可以用于代替MySQL中的TRY
/CATCH
块。如何使用DECLARE HANDLER
在MySQL存储过程中复制这个CATCH
语句的功能呢?
BEGIN CATCH
CLOSE transDetails //cursor name
CLOSE transQuoteOptionDetails//another cursor name
DEALLOCATE transDetails
DEALLOCATE transQuoteOptionDetails
DECLARE @ErrorMessage varchar(2000),@ErrorSeverity tinyint,@ErrorState tinyint
SET @ErrorMessage = ERROR_MESSAGE()
SET @ErrorSeverity = ERROR_SEVERITY()
SET @ErrorState = ERROR_STATE()
Delete From MasterReport_Temp where masterReportRecNo=@masterReportRecNo
Update MasterReport set status=3, errorDescription=@ErrorMessage where recNo=@masterReportRecNo
END CATCH
TRY
块,任何人都不知道错误条件可能是什么? - miken32