Microsoft KB Archive/283842

= FIX: IN and UNION Clauses Produce Incorrect Column Count =

Article ID: 283842

Article Last Modified on 4/7/2006

-

APPLIES TO


 * Microsoft OLE DB Provider for Oracle Server 1.0
 * Microsoft OLE DB Provider for Oracle Server 1.0
 * Microsoft Data Access Components 2.5
 * Microsoft Data Access Components 2.5 Service Pack 1
 * Microsoft Data Access Components 2.6

-



This article was previously published under Q283842



SYMPTOMS
With the Microsoft OLE DB Provider for Oracle (MSDAORA), the execution of a SQL statement that contains both an IN and a UNION clause may produce an ActiveX Data Objects (ADO) Recordset object that contains an incorrect number of columns.

This problem occurs when using an ADO client-side cursor (which means that the CursorLocation property is set to adUseClient) but works correctly when using a server-side cursor.



RESOLUTION
To resolve this problem, obtain the latest service pack for Microsoft MDAC 2.5. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

293312INFO: How to Obtain the Latest MDAC 2.5 Service Pack

To resolve this problem, obtain the latest service pack for Microsoft Data Access Components 2.6. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

300635 INFO: How to Obtain the Latest MDAC 2.6 Service Pack

Hotfix
The English version of this fix should have the following file attributes or later:

  Version       Size      File name     Platform ---  2.53.6007.0   209,168   Msdaora.dll   x86



WORKAROUND
The problem does not occur if you use a server-side cursor; the CursorLocation property is set to adUseServer.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in Microsoft Data Access Components 2.6 Service Pack 2, MDAC 2.5 SP3, and MDAC 2.7.



Steps to Reproduce the Behavior
  Add the following code in a new Visual Basic project, and set a Project Reference to Microsoft ActiveX Data Objects 2.5 Library: Private Sub Command1_Click

Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset cn.Open &quot;Provider=MSDAORA;Data Source=your_oracle_server;User ID=your_user_name;Password=your_password&quot; On Error Resume Next cn.Execute &quot;Drop table oratest&quot; cn.Execute &quot;CREATE TABLE ORATEST(Col1 VARCHAR2(10) NULL,&quot; & _              &quot;Col2 VARCHAR2(10) NULL)&quot; cn.Execute &quot;insert into oratest values(7,7)&quot; cn.Execute &quot; insert into oratest values(6,6)&quot; cn.Execute &quot;Drop table DUAL&quot; cn.Execute &quot;CREATE TABLE DUAL(C11 VARCHAR2(10) NULL,&quot; & _              &quot;C12 VARCHAR2(10) NULL)&quot; cn.Execute &quot;insert into dual values(6,7)&quot; rs.CursorLocation = adUseClient rs.Open &quot;select col1, col2 from oratest where col1 in (Select C11 from dual union select C12 from dual)&quot;, _ cn, adOpenStatic,adLockBatchOptimistic Debug.Print rs.Fields.Count     '<--- incorrect column count Debug.Print rs.Fields(0).Name Debug.Print rs.Fields(1).Name End Sub  When you run the above project, an incorrect number of columns is displayed. You may also see the error &quot;Object was open&quot; when you observe the recordset's Fields count in the Visual Basic Watch window. In this case, the line &quot;Debug.Print rs.Fields.Count&quot; would not print any result in the Immediate window.

Keywords: kbbug kbfix kboracle kbprovider kbqfe kbmdac260sp2fix kbmdac250sp3fix kbhotfixserver KB283842

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.