Unused variable in AbtOdbc30DatabaseConnection method

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

Unused variable in AbtOdbc30DatabaseConnection method

Postby g.cotelli » Fri Sep 03, 2010 1:16 pm

AbtOdbc30DatabaseConnection >>verifyNoError:infoType:hstmt:ifError: declares a temporal errorCollection and made an assignment to it, but later never get read. Using the compiler warning level in 2 shows: "Warning severity 1: Value is written to but never read from" errorCollection.

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';

      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 :=
         ifTrue: [errorData first] "Capture error text."
         ifFalse: [(self getMRI: AbtDbmOdbcNoError group: #AbtMsgDbmBase) asString].

      ifTrue: [
         self prevError: (AbtOrderedDictionary with: (Association key: sqlstate value: errorData))].

      value: (AbtError in: self locus: sqlstate rc: aRc errorText: msgText abrTrimNullsFromEnd)

Posts: 13
Joined: Wed Feb 24, 2010 9:30 am

Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: No registered users and 1 guest