Send feedback on this topic.
Size Property

Teradata.Client.Provider Namespace > TdParameter Class : Size Property
Gets or sets the maximum size for the transmitted data.
Public Overrides NotOverridable Property Size As Integer
Dim instance As TdParameter
Dim value As Integer
instance.Size = value
value = instance.Size
public override int Size {get; set;}
property int Size {
   int get() override;
   void set (    int value) override;

The Size property is used for binary and string types and has different meanings dependent on the data type:

The Size property is ignored for XML output parameters.

When creating a parameter for a character array or a string, the application programmer must be cognizant of the Session Character Set used for logging on to the Teradata database. It is important to understand when to specify the number of bytes or the number of characters.

For example, if a column in a table is defined with the server character sets Kanjisjis or Kanji1, any parameters that refer to these columns must have the DbType property set to DbType.AnsiString. The value of Size must represent the number of bytes of the string to be sent to Teradata.

The following are descriptions of additional scenarios and their expected behaviors:


Scenario: A table that contains a column defined as VARCHAR(20) CHARACTER SET KANJISJIS. The DbType has been set to DbType.AnsiString, the size of this column is defined in bytes (please refer to the "SQL Reference: Data Types and Literals" for more information). The Session Character Set has been set to UTF16. The character array has a length of 8 and contains only ASCII data.

Expected Behavior: Each character in the array will take two bytes of space after being encoded into the UTF16 Session Character Set. If the Size property has been set to 4, then only two characters of the array will be sent to Teradata. If the Size has been set to 20, all 8 characters will be sent.


Scenario: A table contains a parameter declared as VARCHAR(64000) CHARACTER SET LATIN, and the session character set has been set to UTF8. In the application, the DbType is set to DbType.String or DbType.AnsiString and the character array contains ASCII characters. The Size has been set to 32,001.

Expected Behavior: The Teradata database will return an error indicating that the column or character expression is larger than the max size. This is because the maximum size of a VarChar literal in a Unicode session character set is 32,000 characters. There are several ways to avoid this problem:

  1. Specify a Session Character Set that has a fixed-byte number of bytes per character of 1, if possible.An example of such a character set is ASCII.
  2. Use a data type that supports a larger size. For example, set the TdParameter.DbType property to TdType.Clob.


Scenario: The Session Character Set has been set to UTF16. The DbType has been set to DbType.AnsiString. The Size has been set to an odd value.

Expected Behavior: The Teradata database will return an error about a malformed character. In this scenario, the Size must be a multiple of the minimum character length in bytes. Since the minimum character length in bytes for a UTF16 character set is 2, Size must always be an even value.


Target Platforms: Windows 7, Windows 8, Windows 8.1, Windows 10, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2

See Also


TdParameter Class
TdParameter Members