title: Cannot use OracleParameter of type NVarChar with ParameterDirection of Output when calling stored procedure from ADO.NET
body: <p>I am using ADO.Net to call a stored procedure in an Oracle database. The stored procedure has an out parameter that is a NVARCHAR2. Here is the stored procedure:</p>
  
  <pre><code>CREATE OR replace PROCEDURE VALIDATE_Bin ( 
  machine_dump_name IN NVARCHAR2, 
  lpn               IN NVARCHAR2, 
  result            OUT NUMBER, 
  message           OUT NVARCHAR2) 
  IS 
  BEGIN 
      IF lpn LIKE 'A%' THEN 
        result := 1; 
        message := NULL; 
      ELSE 
        IF lpn IS NULL THEN 
          result := 0; 
          message := 'Failed Read'; 
        ELSE 
          result := 0; 
          message := 'Invalid Barcode'; 
        END IF; 
      END IF; 
  END;
  </code></pre>
  
  <p>And here is the c# code to fill in the parameters of the command:</p>
  
  <pre><code>command.Parameters.Add(new OracleParameter("machine_dumper_name",OracleType.NVarChar){Value = "My Dumper"});
  command.Parameters.Add(new OracleParameter("lpn", OracleType.NVarChar) { Value ="XYZ1234"});
  var resultParam = new OracleParameter("result", OracleType.Number) { Direction = ParameterDirection.Output};
  command.Parameters.Add(resultParam);
  var messageParam = new OracleParameter("message", OracleType.NVarChar) { Direction = ParameterDirection.Output};
  command.Parameters.Add(messageParam);
  
  command.ExecuteNonQuery();
  </code></pre>
  
  <p>If I execute it like this I get the exception:</p>
  
  <blockquote>
    <p>System.Exception: Parameter 'message': No size set for variable length data type: String.</p>
  </blockquote>
  
  <p>No worries I think. Oracle expects a string length on the "message" parameter. So I add a size parameter on the "message" parameter:</p>
  
  <pre><code>var messageParam = new OracleParameter("message", OracleType.NVarChar, 255) { Direction = ParameterDirection.Output};
  </code></pre>
  
  <p>and then when I run it I get this System.Data.OracleClient.OracleException:</p>
  
  <blockquote>
    <p>PLS-00306: wrong number or types of arguments in call to 'VALIDATE_Bin'</p>
  </blockquote>
  
  <p>How the heck am I supposed to call this procedure and get the message out? I think this problem is specific to string data types. Is this a bug? Or am I doing something wrong?</p>