FIX: IN and UNION Clauses Produce Incorrect Column Count

Article translations Article translations
Article ID: 283842 - View products that this article applies to.
This article was previously published under Q283842
Expand all | Collapse all

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.

MORE INFORMATION

Steps to Reproduce the Behavior

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

Properties

Article ID: 283842 - Last Review: April 7, 2006 - Revision: 6.1
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
Keywords: 
kbqfe kbhotfixserver kbmdac250sp3fix kbbug kbfix kbmdac260sp2fix kboracle kbprovider KB283842

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com