Hello,
I have had a little time to debug the TZInterbaseFirebirdConnection.HandleErrorOrWarning() method.
Code: Select all
unit ZDbcFirebirdInterbase
procedure TZInterbaseFirebirdConnection.HandleErrorOrWarning()
...
InterbaseStatusVector := InterpretInterbaseStatus(StatusVector);
ErrorCode := InterbaseStatusVector[0].SQLCode;
ErrorString := '';
for i := Low(InterbaseStatusVector) to High(InterbaseStatusVector) do begin
AppendSepString(ErrorString, InterbaseStatusVector[i].IBMessage, '; ');
if AddLogMsgToExceptionOrWarningMsg and (InterbaseStatusVector[i].IBMessage = '') then
AppendSepString(ErrorString, InterbaseStatusVector[i].SQLMessage, '; ');
end;
...
I found something, maybe it will help.
1. Error executing a stored procedure - the types of formal and actual parameters do not matches.
Debugging:
Code: Select all
ErrorCode := InterbaseStatusVector[0].SQLCODE = -303
InterbaseStatusVector[0].IBDataInt (== GDSCODE) = 335544569
i = 0
InterbaseStatusVector[i].IBMessage = 'Dynamic SQL Error'
InterbaseStatusVector[i].SQLMessage = 'Incompatible column/host variable data type'
InterbaseStatusVector[i].SQLCODE = -303
InterbaseStatusVector[i].IBDataInt (== GDSCODE) = 335544569
i = 1
InterbaseStatusVector[i].IBMessage = 'SQL error code = -303' <== Maybe when returning the error from this status vector element, it was better to display SQLMessage, and not IBMessage?
InterbaseStatusVector[i].SQLMessage = 'Incompatible column/host variable data type'
InterbaseStatusVector[i].SQLCODE = -303
InterbaseStatusVector[i].IBDataInt (== GDSCODE) = 335544436
i = 2
InterbaseStatusVector[i].IBMessage = 'arithmetic exception, numeric overflow, or string truncation'
InterbaseStatusVector[i].SQLMessage = 'Arithmetic overflow or division by zero has occurred.'
InterbaseStatusVector[i].SQLCODE = -802
InterbaseStatusVector[i].IBDataInt (== GDSCODE) = 335544321
i = 3
InterbaseStatusVector[i].IBMessage = 'string right truncation'
InterbaseStatusVector[i].SQLMessage = 'Arithmetic overflow or division by zero has occurred.'
InterbaseStatusVector[i].SQLCODE = -802
InterbaseStatusVector[i].IBDataInt (== GDSCODE) = 335544914
i = 4
InterbaseStatusVector[i].IBMessage = ''
InterbaseStatusVector[i].SQLMessage = 'This user does not have privilege to perform this operation on this object.'
InterbaseStatusVector[i].SQLCODE = -551
InterbaseStatusVector[i].IBDataInt (== GDSCODE) = 335545033
Resulting error message:
Code: Select all
SQL Error: Dynamic SQL Error; SQL error code = -303; arithmetic exception, numeric overflow, or string truncation; string right truncation; This user does not have privilege to perform this operation on this object.
Code: -303
As you can see, the final message does not contain a true cause of the error:
'Incompatible column/host variable data type'.
This happened due to the IF operator:
Code: Select all
if AddLogMsgToExceptionOrWarningMsg and (InterbaseStatusVector[i].IBMessage = '') then
AppendSepString(ErrorString, InterbaseStatusVector[i].SQLMessage, '; ');
In this situation, both fields are filled - and IBMessage, and SQLMessage.
It would be good in such a situation somehow combine these error messages.
Also, starting with Firebird v.2.5.1 SQLCODE context variable is deprecated, and instead is recommend to use SQLSTATE.
However, in this method (HandleErrorOrWarning), the error message returns only SQLCODE, but SQLSTATE and GDSCODE contained in the InterbaseStatusVector[0].IBDataInt field, are not returned.
I think, it would be most informative to return all three context variables: SQLSTATE, GDSCODE and SQLCODE.
2. Error connecting to a database due to an incorrect username / password.
Debugging:
There is only one element in the Firebird status vector:
Code: Select all
ErrorCode := InterbaseStatusVector[0].SQLCODE = -902
InterbaseStatusVector[0].IBDataInt (== GDSCODE) = 335544472 (== 'Your user name and password are not defined. Ask your database administrator to set up a Firebird login')
Resulting error message:
Code: Select all
SQL Error: Unsuccessful execution caused by a system error that precludes successful execution of subsequent statements
Code: -902
As you can see, a detailed description of the error did not fall into the final message:
'Your user name and password are not defined. Ask your database administrator to set up a Firebird login'.
Here I could not understand why this message is missing, I did not meet it anywhere under the debugger.
Maybe it can somehow be obtained by GDSCODE.