Subject RE: [Firebird-Architect] Re: SQLSTATE and Firebird
Author Tom Cole
[Sorry for the delay in weighing back in, I was out of office.]

Here's an example of a problematic error: isc_arith_except.

This is signaled in many places from within cvt.cpp and evl.cpp. It can means overflow, string truncation, or math domain errors such as divide-by-zero.

There are discrete SQLSTATE values for these. Consider Oracle's list:

01004 String data right truncated
22012 Division by zero
22003 Numeric value out of range

The isc_arith_except error is thrown from a variety of places where the context of the operation is necessary to know how to interpret which SQLSTATE to apply. This would be a case where I think that the actual error signaler has to add some value or data to describe what is happening - it's not possible for a status vector post-processor to know which is which.

-----Original Message-----
From: [] On Behalf Of Alex Peshkov
Sent: Wednesday, April 26, 2006 6:50 AM
Subject: Re: [Firebird-Architect] Re: SQLSTATE and Firebird

Roman Rokytskyy wrote:
>>AFAIU, this could (should?) be achieved via a mapping table between
>>GDSCODE's and SQLSTATE's (similarly to how SQLCODE's are handled) +
>>one new API function (fb_sqlstate?). This way, GDSCODE's are still the
>>primary error ids and nothing in the engine needs to be modified. The
>>client passes the status vector to fb_sqlstate() and gets SQLSTATE
>>value. PSQL code may be extended to support WHEN SQLSTATE <value>
>>Am I missing something?
> No, I have used similar approach in Jaybird. The only problem is that
> there are only few SQLSTATEs that map nicely to Firebird:

What problems, with, for example:
08001 - client unable to establish connection

is not it where we should map isc_network_error:
Unsuccessful execution caused by a system error that precludes successful execution of subsequent statements.
Unable to complete network request to host "QQ".
Failed to locate host machine.
The specified name was not found in the hosts file or Domain Name Services.

Moreover, if some of SQLSTATEs will not be used, that's not a big problem - this simply means, that such errors never happen in firebird.
The more serious problem will happen if we will not be able to map particular gdscode to SQLSTATE. Or if we will need to map it to different SQLSTATEs in different cases. But before trying to solve that problems, let's make sure they really happen.

Yahoo! Groups Links