Article ID: 328514 - Last Review: November 15, 2007 - Revision: 4.5

FIX: Binding an output parameter of an Oracle stored procedure to adBSTR results in an incorrect value

Hotfix download is availableHotfix Download Available
View and request hotfix downloads
This article was previously published under Q328514

On This Page

Expand all | Collapse all

SYMPTOMS

When you bind a varchar2 type output parameter of an Oracle stored procedure to adBSTR in a Microsoft ADO application, the value that Microsoft OLE DB provider for Oracle (MSDAORA) returns is incorrect. In a Microsoft Visual Basic application the output parameter is "????", and in a Microsoft Visual C++ application, the output parameter is a truncated ANSI value.

CAUSE

This occurs because of a bug in MSDAORA. Although the output parameter data type is marked as DBTYPE_WSTR internally, the data itself is not converted to Unicode before it is sent to the data conversion layer.

RESOLUTION

A supported hotfix is available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next software update that contains this hotfix.

If the hotfix is available for download, there is a "Hotfix download available" section at the top of this Knowledge Base article. If this section does not appear, contact Microsoft Customer Service and Support to obtain the hotfix.

Note If additional issues occur or if any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. For a complete list of Microsoft Customer Service and Support telephone numbers or to create a separate service request, visit the following Microsoft Web site:
http://support.microsoft.com/contactus/?ws=support (http://support.microsoft.com/contactus/?ws=support)
Note The "Hotfix download available" form displays the languages for which the hotfix is available. If you do not see your language, it is because a hotfix is not available for that language. The English version of this hotfix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.

MDAC 2.7

    Date           Version           Size              File name     
    ------------------------------------------------------------
    30-Aug-2002    2.70.9001.20    221,184 bytes     Msdaora.dll
				
The English version of this hotfix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.

MDAC 2.7 Service Pack 1 (SP1)

    Date           Version           Size              File name     
    ------------------------------------------------------------
    06-12-2003    2.71.9031.45    221,184 bytes     Msdaora.dll
				
The English version of this hotfix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.

MDAC 2.8

    Date           Version           Size              File name     
    ------------------------------------------------------------
   27-Feb-2004  18:29  2.80.1035.0       225,280  Msdaora.dll      
   27-Feb-2004  18:29  2000.85.1035.0     24,576  Odbcbcp.dll      
   27-Feb-2004  18:28  2000.85.1035.0    401,408  Sqlsrv32.dll     

				
Note For a list of all the hotfixes available for MDAC 2.8, click the following article number to view the article in the Microsoft Knowledge Base:
839801  (http://support.microsoft.com/kb/839801/ ) FIX: Hotfixes are available for MDAC 2.8

WORKAROUND

To work around this problem, bind the output parameter of varchar2 to adVarchar instead of to adBSTR.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

Steps to reproduce the behavior

  1. Run the following script to create a stored procedure that is named sp_param:
    CREATE OR REPLACE PROCEDURE sp_param
    (IN_PARAM IN VARCHAR2,RET_Result OUT VARCHAR2)               
    AS               
    BEGIN               
      RET_Result := IN_PARAM;               
    END; 
    	
  2. In Visual Basic 6.0, create a Standard EXE project.
  3. Add a reference to the Microsoft ActiveX Data Objects library. To do this, follow these steps:
    1. On the Project menu, click Add Reference.
    2. Click the COM tab, click to select Microsoft ActiveX Data Objects 2.7 Library, click Select, and then click OK.
  4. Add a CommandButton control to the main Form.
  5. Double-click the Command button. Paste the following code in the Command1_Click() event handler:
    Private Sub Command1_Click()
    Dim oConn As New ADODB.Connection
    Dim oCmd As New ADODB.Command
    Dim oRsReport As ADODB.Recordset
     
    oConn.ConnectionString = "Provider=MSDAORA;Data Source=myOraServer;User Id=scott;Password=tiger;"
    oConn.Open
     
    oCmd.ActiveConnection = oConn
    oCmd.CommandText = "sp_param"
    oCmd.CommandType = adCmdStoredProc
     
    With oCmd
        .Parameters.Append .CreateParameter("in_param", adVarChar, adParamInput, 50, "Testing 123")
        .Parameters.Append .CreateParameter("ret_result", adBSTR, adParamOutput, 50)
    End With
     
    Set oRsReport = oCmd.Execute
     
    Debug.Print oCmd.Parameters.Item("ret_result")
    oRsReport.Close
    oConn.Close
     
    Set oRsReport = Nothing
    Set oConn = Nothing
    Set oCmd = Nothing
     
    End Sub
  6. Change the connection string as appropriate for your environment. Save and then run the project.

APPLIES TO
  • Microsoft OLE DB Provider for Oracle Server 1.0
  • Microsoft ActiveX Data Objects 2.7
  • Microsoft Data Access Components 2.8
Keywords: 
kbautohotfix kbhotfixserver kbqfe kbmdac280presp1fix kbbug kbfix kboracle kbqfe KB328514
 

Article Translations