我正在尝试将存储过程从SQL Server迁移到MySQL。在try catch块的转换过程中,我遇到了一些问题。我知道DECLARE HANDLER
可以用来代替MySQL中的TRY
/CATCH
块。如何使用DECLARE HANDLER
在MySQL存储过程中复制此CATCH
语句的功能?什么是SQL服务器的try catch块的mysql等价物
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 [email protected]
Update MasterReport set status=3, [email protected] where [email protected]
END CATCH
正如您必须阅读,您声明了处理特定错误条件的处理程序。在没有看到TRY块的情况下,谁能知道错误情况会是什么? – miken32
谢谢@ miken32,我想知道是否有一种方式即时通讯MySQL的存储过程,当某些阶段发生错误时,然后一些stetement执行像UPDATE,DELETE和CREATE语句将execute.please给我如果可能的代码 –