Question

We have been facing a small problem in MySQL procedure. 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)?

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). 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? 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.

Was it helpful?

Solution

At this time, there is no way we could examine the current MYSQL Error code or SQLSTATE code in Store Procedure. It's SQL:2003 Features that is not currently implemented on MYSQL Stored program.

You should check this: http://www.docstoc.com/docs/687360/Error-Handling-In-Stored-Procedure

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top