Search code examples
c#.netoracle-databasedata-access-layerodp.net

What's the OracleParameter.Size influence?


When developing an app that uses ODP .NET in DAL it's very annoying always set the Size property of OracleParameter. For instance:

getSPTimeCommand.Parameters.Add("pStartTime", OracleDbType.Varchar2, ParameterDirection.Output).size = 200;

Isn't was so ugly? Thinking about auto set the Size parameter of OracleParameter I thought about it influence on performance or memory consuming. What is that influence? What is your scenario for setting a Size?

Thanks in advance!


Solution

  • From the documentation:

    Specifies the maximum size, in bytes or characters, of the data transmitted to or from the database. For PL/SQL Associative Array Bind, Size specifies the maximum number of elements in PL/SQL Associative Array.

    In your case it is the maximum size of the varchar2 you're passing to the database.