I removed that from the code to keep it shorter, maybe this can be included in the base image. Updated Code:
- Code: Select all
verifyNoError: aRc infoType: anInfoType hstmt: aHstmt ifError: anErrorBlock
"
Check the completion status of the last function.
Answer one of the following:
1. ... true if there was no error.
2. ... Sql_Success_With_Info (integer value)
3. ... The result of an (anErrorBlock value: ae),
where ae is an instance of AbtError describing
the error.
Note: If aRc is already an AbtError then no further work is done
analyzing the error text. (anErrorBlock value: aRc) will
be answered in this case.
"
| msgArray msgText errorData sqlstate gotOdbcErrorInfo |
aRc isAbtError ifTrue: [^anErrorBlock value: aRc].
aRc = Sql_Success ifTrue: [^true].
aRc = Sql_Success_With_Info "Special case: Make sure this value is passed to inform calling methods"
ifTrue: [^aRc].
"
It looks like an error, so let's extract and format the error information.
"
aRc = Sql_Invalid_Handle
ifTrue: [
^AbtError new
rc: Sql_Invalid_Handle;
errorText: 'Sql_Invalid_Handle';
yourself].
"
The first element of msgArray will be the SQL State. The following elements
will be the error data. The first element of the error data (the 2nd
element of the msgArray) will be an error description string.
"
msgArray := self nextErrorForInfoType: anInfoType hstmt: aHstmt.
sqlstate := msgArray at: 1.
errorData := (msgArray copyFrom: 2 to: msgArray size) asOrderedCollection.
gotOdbcErrorInfo := errorData first notNil and: [errorData first size > 0].
msgText :=
gotOdbcErrorInfo
ifTrue: [errorData first] "Capture error text."
ifFalse: [(self getMRI: AbtDbmOdbcNoError group: #AbtMsgDbmBase) asString].
gotOdbcErrorInfo
ifTrue: [
self prevError: (AbtOrderedDictionary with: (Association key: sqlstate value: errorData))].
^anErrorBlock
value: (AbtError in: self locus: sqlstate rc: aRc errorText: msgText abrTrimNullsFromEnd)
Regards,
Gabriel