ODBC Error Handling

From CometWiki

(Difference between revisions)
Jump to: navigation, search
Line 27: Line 27:
“Local:” Indicates an internal driver error.
“Local:” Indicates an internal driver error.
<Type>
<Type>
-
“D” if the error occurred during a Database command.
+
“D” if the error occurred during a Database command.
-
        “R” if the error occurred during a Recordset command.
+
“R” if the error occurred during a Recordset command.
<ErrorNum> One of the following errors:
<ErrorNum> One of the following errors:

Revision as of 10:06, 29 May 2009

ODBC Error Handling

Error Generation

When using the CONTROL function, error information (if any) will be contained in the returned <Result> string.

When an Internal or ODBC error occurs during a Read or Write operation, the error information must be obtained from the driver using the dbGetLastError command.

Example:

   Write (Lun, RSDefinition) Excp = BadDefinition
   .
   .
   Return
   .
   BadDefinition:
       Result$ = Control(Lun, "dbGetLastError")
       Print Result$
       Goto Abort
   .
   Error Interpretation

Internal errors generated by the Comet ODBC driver are returned in the form of:-
“Local:<Type><ErrorNum> <ErrorDescription>”
where:

“Local:” Indicates an internal driver error. <Type>

“D” if the error occurred during a Database command.
“R” if the error occurred during a Recordset command.

<ErrorNum> One of the following errors:

Database Errors: DBERR.NONE // 0-No error DBERR.CMDINVALID // 1-Invalid command DBERR.SYSTEM // 2-Non CDatabase thrown exception DBERR.ODBC // 3-CDatabase thrown exception DBERR.FUNCTION // 4-Function failed (BOOL) DBERR.INVPARAM // 5-Invalid command parameter DBERR.RSINVALID // 6-Invalid or unknown recordset

               DBERR_NOTOPEN		//  7 - Database is not open

Recordset Errors: RSERR.NONE // 0-No error RSERR.CMDINVALID // 1-Invalid command RSERR.SYSTEM // 2-Non CRecordset thrown exception RSERR.ODBC // 3-CRecordset thrown exception RSERR.FUNCTION // 4-Function failed RSERR.INVPARAM // 5-Invalid command parameter RSERR.INVTYPE // 6-Incorrect Internet Basic type for SQL type RSERR.TYPENOSUP // 7-SQL type not supported RSERR.INVWRITE // 8-Unexpected write RSERR.EOF // 9-End of File RSERR.INVBOOKMARK // 10-Invalid bookmark RSERR.EXPWRITE // 11-Write was expected RSERR.INVCOLUMN // 12-Bind Column not found RSERR.DATAERROR // 13-Loss of data would occur

               RSERR_INVMAP		// 14-Invalid item in map
               RSERR_NOTOPEN		// 15-Recordset is not open

Errors returned by the ODBC driver are returned in the following forms:

If the “ErrorCodes” option was NOT specified when the Database object was created the error string will be in the form of a use decipherable message.

If the “ErrorCodes” option was specified when the Database object was created the error string will be:

“State:<strState>,Native:<nNative>,Origin:<strErrorMsg>

<strState> A five-character error code returned in the szSqlState parameter <nNative> The native error code, specific to the data source. <strErrorMsg > The error message text returned in the szErrorMsg parameter of the ::SQLError function. This message consists of several bracketed names. As an error is passed from its source to the user, each ODBC component (data source, driver, Driver Manager) appends its own name. This information helps to pinpoint the origin of the error.

Personal tools