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



The information in this article applies to:

  • Microsoft OLE DB Provider for Oracle 2.7
  • ActiveX Data Objects (ADO) 2.7
  • Microsoft Data Access Components 2.8

This article was previously published under Q328514

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 now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Microsoft Data Access Components service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question. 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 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.

Modification Type:MinorLast Reviewed:10/11/2005
Keywords:kbHotfixServer kbQFE kbMDAC280presp1fix kbbug kbfix kbOracle kbQFE KB328514 kbAudDeveloper