|
A deprecated ODBC function SQLError detects wrong size of an error
message in some cases (for example with Oracle9/Merant ODBC), I have
fixed it with messages "trimNulls trimBlanks".
-------------------------
DBExceptionDetails>>buildErrorInfo
"Private - Retrieve all error information available from the ODBC
Driver
for my handles, unless none is found in which case
a 'reduced' error is created using the return code from function
which caused the error"
(code ~~ SQL_SUCCESS and: [code ~~ SQL_INVALID_HANDLE])
ifTrue:
[| szSqlState fNativeError szErrorMsg cbErrorMsg |
szSqlState := String new: SQL_STATE_SIZE + 1.
szErrorMsg := String new: 512.
cbErrorMsg := SWORD new.
fNativeError := SDWORD new.
[(ODBCLibrary default
sqlError: hEnv
hdbc: hDBC
hstmt: hStmt
szSqlState: szSqlState
pfNativeError: fNativeError
szErrorMsg: szErrorMsg
cbErrorMsgMax: szErrorMsg size
pcbErrorMsg: cbErrorMsg) = SQL_SUCCESS]
whileTrue:
[| newErr |
newErr := DBErrorDetails
fromSQLError: (szErrorMsg copyFrom: 1 to: cbErrorMsg
asInteger) trimNulls trimBlanks.
newErr
nativeErr: fNativeError asInteger;
sqlState: (szSqlState copyFrom: 1 to: 5).
self addErrorDetails: newErr]].
errors isNil ifTrue: [self retCodeError: code]
-------------------------
Dmitry Zamotkin
|