Microsoft Knowledge Base Email Alertz

(283842) - 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...

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 283842 - Last Review: April 7, 2006 - Revision: 6.1

FIX: IN and UNION Clauses Produce Incorrect Column Count

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:
293312  (http://kbalertz.com/Feedback.aspx?kbNumber=293312/EN-US/ ) INFO: 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  (http://kbalertz.com/Feedback.aspx?kbNumber=300635/EN-US/ ) 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.

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
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate