简体   繁体   English

MySQL过程中的错误代码

[英]Errorcode in MySQL procedure

We have been facing a small problem in MySQL procedure. 我们一直在MySQL过程中遇到一个小问题。 We have placed some exception handlers inside the procedure. 我们在过程中放置​​了一些异常处理程序。 But we want to retrieve the errorcode of any error that can occur inside a procedure. 但是我们希望检索过程内部可能发生的任何错误的错误代码。 Is there any way to get the exact errorcode using some kind of function (in the same way, we use WSAGetLastError in the socket APIs)? 是否可以使用某种函数来获取确切的错误代码(以相同的方式,我们在套接字API中使用WSAGetLastError)?

for example, suppose there is a select query inside a procedure which refers to a nonexisting table. 例如,假设在一个过程中有一个选择查询,它引用一个不存在的表。 In that case, an error will be generated ('table' donot exist). 在这种情况下,将生成错误(“表”不存在)。 The control will get transferred to the exception handlers but without any meaning information. 该控件将被转移到异常处理程序,但没有任何含义信息。 we can handle it using the exact error code in this case (1146). 在这种情况下(1146),我们可以使用确切的错误代码进行处理。 but what if the error is something else, that we havent mentioned in the exception handler? 但是如果错误是我们在异常处理程序中没有提到的其他错误,该怎么办? we want to get the error code in that case for checking later. 在这种情况下,我们想获取错误代码以供以后检查。 there is a SHOW ERRORS query but how to use it in a procedure for processing? 有一个SHOW ERRORS查询,但是如何在处理过程中使用它? i hope this is more clear. 我希望这更加清楚。

i found the question here also: http://www.eggheadcafe.com/software/aspnet/35923137/show-errors-question.aspx but noone has answered yet. 我在这里也找到了问题: http ://www.eggheadcafe.com/software/aspnet/35923137/show-errors-question.aspx,但没有人回答。

At this time, there is no way we could examine the current MYSQL Error code or SQLSTATE code in Store Procedure. 目前,我们无法在存储过程中检查当前的MYSQL错误代码SQLSTATE代码 It's SQL:2003 Features that is not currently implemented on MYSQL Stored program. 这是SQL:2003功能 ,目前尚未在MYSQL存储程序上实现。

You should check this: http://www.docstoc.com/docs/687360/Error-Handling-In-Stored-Procedure 您应该检查以下内容: http : //www.docstoc.com/docs/687360/Error-Handling-In-Stored-Procedure

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM