FIX: .NET Provider for Oracle Generates ORA-01458 When Calling an SP That Has More Than One Output Parameter (329163)



The information in this article applies to:

  • Microsoft ADO.NET (included with the .NET Framework) 1.0

This article was previously published under Q329163

SYMPTOMS

With Microsoft .NET Managed Provider for Oracle, when you try to execute an Oracle stored procedure that has more than one output parameter of data type Number, you receive the following error message:
ORA-01458: invalid length inside variable character string

CAUSE

This error occurs because of a bug in Microsoft .NET Managed Provider for Oracle.

RESOLUTION

A supported fix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Apply it only to computers that are experiencing this specific problem. This fix may receive additional testing. Therefore, if you are not severely affected by this problem, Microsoft recommends that you wait for the next that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone 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 typical support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

The P1 version of this fix 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.
   Date         Time   Version       Size    File name
   ----------------------------------------------------------------------
   19-Sep-2002  21:57  1.0.1080.0   290,816  System.data.oracleclient.dll  
				

WORKAROUND

To work around this problem, use one of the following methods:
  • If you manually set the parameters, you can change the direction of the output parameters of type Number from Output to InputOut, and set a value of 0.
  • If you are retrieving parameter information by means of the OracleCommandBuilder.DeriveParameters method, there is no direct workaround. You have to install this hotfix, or wait for the next release that includes this hotfix.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create the following Oracle package:
    CREATE OR REPLACE PACKAGE AA_TEST AS
       PROCEDURE Test1(
            val_in       IN    NUMBER,
            val_out1     OUT   NUMBER,
            val_out2     OUT   NUMBER
            );
    END;
    
    
    CREATE OR REPLACE PACKAGE BODY AA_TEST
    IS
       PROCEDURE Test1(
            val_in       IN    NUMBER,
            val_out1     OUT   NUMBER,
            val_out2     OUT   NUMBER
            )
        IS
        BEGIN
          val_out1 := val_in + 1 ;
          val_out2 := val_in + 2 ;
        END;
    
    END aa_test;
    					
  2. Create a new Visual C# Windows Application project:
    1. Start Microsoft Visual Studio .NET.
    2. On the File menu, point to New, and then click Project.
    3. Click Visual C# Projects under Project Types, and then click Windows Application under Templates. By default, Form1 is added to the project.
    4. On the Project menu, click Add Reference, and then set a reference to the System.Data.OracleClient namespace.
    5. Drag a Button control from the toolbox to the form.
    6. Add the following code at the top of the Code window:
      using System.Data.OracleClient 
      						
    7. Add the following code to the Button1_Click event of Form1:
                   OracleConnection conn = new OracleConnection("Data Source=myOraSrv;User ID=scott;password=tiger");
                   try
                   {
                        conn.Open();
                        OracleCommand cmd =  new
                        OracleCommand("AA_TEST.Test1", conn); 
      
                        OracleParameter param1 = new OracleParameter("val_in", OracleType.Number);
                        param1.Direction = ParameterDirection.Input;
                        param1.Value = 80;
                        cmd.Parameters.Add(param1);
                        OracleParameter param2 = new OracleParameter("val_out1", OracleType.Number);
      
                        param2.Direction = ParameterDirection.Output;
                        cmd.Parameters.Add(param2);
      
                        cmd.Parameters.Add("val_out2",OracleType.Number).Direction =ParameterDirection.Output; 
                        cmd.CommandType =System.Data.CommandType.StoredProcedure;
                        cmd.ExecuteScalar();
                        MessageBox.Show (cmd.Parameters["val_out2"].Value.ToString());
                        }
                    catch(OracleException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
      						
      
    8. Modify the "OracleConnection" string as appropriate for your environment.
    9. Press F5 to compile and to run the application.

REFERENCES


Modification Type:MinorLast Reviewed:10/11/2005
Keywords:kbHotfixServer kbQFE kbbug kbfix KB329163