我正在嘗試將存儲過程從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給我如果可能的代碼 –