FIX: Oracle Numeric Fields Must Be Converted for Logical Tests (178043)
The information in this article applies to:
- ActiveX Data Objects (ADO) 1.0
- ActiveX Data Objects (ADO) 1.5
- ActiveX Data Objects (ADO) 2.0
- ActiveX Data Objects (ADO) 2.1 SP2
- ActiveX Data Objects (ADO) 2.5
This article was previously published under Q178043 SYMPTOMS
When you use an Oracle numeric field a "Type Mismatch" error occurs.
The error occurs in the following two scenarios: CAUSE
The following two conditions cause this behavior:
- Storing Integer data in an Oracle Numeric data type field.
- Using the value of the Oracle Numeric field in computations with
Integer data types.
Oracle does not have an Integer data type, only Numeric. The problem is
that numeric types are data with exact precision and scale and must be
converted to another data type comparable to integers. Floating point
numbers are approximate values and can be compared to integers without
exception. For numerics (or the older and equivalent decimal data type) if
this conversion does not take place a type mismatch error occurs.
RESOLUTION
The following conversion functions return values that are comparable to
integers:
For maximum efficiency and flexibility, the CLng() function is recommended.
In the scenarios listed in the SYMPTOMS section, making the following
changes correct the problem:
If CLng(Oracle_Recordset("my_numeric_field"))=1 then ...
x=CLng(Oracle_Recordset("my_numeric_field"))+ 1 STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
This problem was corrected in MDAC 2.1 SP2.
MORE INFORMATION
Oracle uses a numeric data type. If an integer value is stored in a numeric
field, some ODBC drivers (for example, Intersolv version 3.01) returns a
data type of double-precision floating point (that is, VBScript VarType of
5); other drivers (for example, Microsoft ODBC for Oracle version
2.73.7269) more accurately returns numeric data type (that is, VBScript
VarType 14). In all cases, the ADO Type property returns type 131 (that is,
numeric).
Modification Type: | Minor | Last Reviewed: | 3/2/2005 |
---|
Keywords: | kb3rdparty kbADO210sp2fix kbbug kbDatabase kbDSupport kbMDAC210SP2fix kbMDACNoSweep kbOracle kbQFE KB178043 |
---|
|