Microsoft KB Archive/329163

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

Article ID: 329163

Article Last Modified on 10/11/2005

-

APPLIES TO


 * Microsoft ADO.NET 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:

http://support.microsoft.com/contactus/?ws=support

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.



Steps to Reproduce the Behavior
  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;  Create a new Visual C# Windows Application project:  Start Microsoft Visual Studio .NET. On the File menu, point to New, and then click Project.</li> Click Visual C# Projects under Project Types, and then click Windows Application under Templates. By default, Form1 is added to the project.</li> On the Project menu, click Add Reference, and then set a reference to the System.Data.OracleClient namespace.</li> Drag a Button control from the toolbox to the form.</li>  Add the following code at the top of the Code window: using System.Data.OracleClient </li>  Add the following code to the Button1_Click event of Form1: OracleConnection conn = new OracleConnection(&quot;Data Source=myOraSrv;User ID=scott;password=tiger&quot;); try {                 conn.Open; OracleCommand cmd = new OracleCommand(&quot;AA_TEST.Test1&quot;, conn);

OracleParameter param1 = new OracleParameter(&quot;val_in&quot;, OracleType.Number); param1.Direction = ParameterDirection.Input; param1.Value = 80; cmd.Parameters.Add(param1); OracleParameter param2 = new OracleParameter(&quot;val_out1&quot;, OracleType.Number);

param2.Direction = ParameterDirection.Output; cmd.Parameters.Add(param2);

cmd.Parameters.Add(&quot;val_out2&quot;,OracleType.Number).Direction =ParameterDirection.Output; cmd.CommandType =System.Data.CommandType.StoredProcedure; cmd.ExecuteScalar; MessageBox.Show (cmd.Parameters[&quot;val_out2&quot;].Value.ToString); }             catch(OracleException ex) {                 MessageBox.Show(ex.Message); }                       </li> Modify the &quot;OracleConnection&quot; string as appropriate for your environment.</li> Press F5 to compile and to run the application.</li></ol> </li></ol>

<div class="references_section">