>Is there a way to get the error code and message of the last SQL error?
>
>Here's my situation:
>
>I call into a method and pass a SQL string which gets dynamically executed in the called method, but if it causes and error (i.e. if it has an invalid SQL syntax or a bad Order By clause), and then when I check AERRORS(), I get the error of the local call to the worker method, rather than the SQL error that I want to discover.
>
>I cannot touch the called method code to modify it to handle this, since it is part of another framework that I cannot edit. I must find a way to handle this in my wrapper method.
>
>Here is the code I have, but AERRORS() returns info about the call to DoSelect() and not the failure of the SQL statement that I passed in.
>
>
>
>Try
> lnReturn = DoSelect(lcSQL)
>Catch
> AError(laErrors)
>
> If laErrors(1) = 1832
> This.SetError(This.Class + ' SQL ERROR:' + laErrors(2), laErrors(1))
> Endif
>
> lnReturn = -1
>Endtry
>
The only way is to fix DoSelect procedure to return information about the error.
If it's not broken, fix it until it is.
My Blog