Send feedback on this topic.
Teradata.Client.Provider
VarByte Data Type
.NET Data Provider for Teradata > Developer's Guide > Data Types > Byte Data Types > VarByte Data Type

Schema Collections

The Schema collections return metadata for the Advanced SQL Engine objects. The notable metadata columns for the VarByte data type are:

Column Name Description

COLUMN_TYPE

or

DATA_TYPE

Set to VARBYTE.
CHARACTER_OCTET_LENGTH Returns the maximum length of the column in Bytes.
PROVIDERDBTYPE It is set to TdType.VarByte.

Schema Table

The TdDataReader.SchemaTable returns result set metadata. The notable metadata columns for the VarByte data type are:

Column Name Description
ColumnSize Returns the maximum length of the column in Bytes.
DataType System.Type object for the System.Byte[] type.
ProviderType Set to TdType.VarByte.
Format Format assigned to the SQL Engine object.
ProviderSpecificDataType System.Type object for the System.Byte[] class.

Configuring Parameters

The following example shows how to configure a VarByte parameter using DbType type declaration and a BCL value. The value is set to a System.Byte[] instance.

Note

The Data Provider maps DbType.Binary to TdType.Clob when the TdParameter.Size property value is greater than 64,000 bytes.

C#
Copy Code
TdParameter customerPicture = new TdParameter();
customerPicture.ParameterName = "customerPicture";

customerPicture.DbType = DbType.Binary;

customerPicture.Value = pictureBuffer;

The following example shows how to configure a VarByte parameter using TdType type declaration and a BCL value. The value is set to a System.Byte[] instance.

C#
Copy Code
TdParameter customerPicture= new TdParameter();
customerPicture.ParameterName = "customerPicture";

customerPicture.TdType = TdType.VarByte;

customerPicture.Value = pictureBuffer;

The TdParameter.Value must be set to an Array of Bytes (Byte[]).

Set TdParameter.Size Property for InputOutput or Output Parameters

The TdParameter.Size property must be set to a number greater than Zero for InputOutput or Output Parameters. The Data Provider will throw an exception when TdParameter.Direction property is set to ParameterDirection.Output or ParameterDirection.InputOutput and TdParameter.Size property is set to Zero. The TdParameter.Size property specifies the maximum number of Bytes the Data Provider will send to the SQL Engine and/or will receive from the SQL Engine. We recommend to set the TdParameter.Size property to the corresponding SQL Engine object size (e.g. Column or Stored Procedure Parameter size) for Input, InputOutput or Output parameters.

Note

The Data Provider will truncate the data when the TdParameter.Size property value is less than the length of the Data received from the SQL Engine.

Note

TdParameter.Size is not required for Input parameters. However it will improve the overall performance of Batch Updates. Therefore the general guideline is to always set the TdParameter.Size property.

Specifying VarByte as Literal

The syntax for the BYTE Literal is 'hexadecimal digits'XBV. For example 'C1C0'XBV declares a VARBYTE(2) literals; the first byte is set to C1 and and the second byte is set to C0.

Note

We recommend to always use Parameters in order to take advantage of the SQL Engine's Request Cache.

Retrieving VarByte Data

The following methods and properties return the column or parameter value as a System.Byte[] object.

  1. TdDataReader.GetBytes
  2. TdDataReader.GetValue
  3. TdDataReader.GetProviderSpecificValue
  4. TdDataReader.GetFieldValue<Byte[]>
  5. TdParameter.Value
  6. TdParameter.GetValue<Byte[]>

The following method returns the column value as a System.Stream object.

  1. TdDataReader.GetStream
  2. TdDataReader.GetFieldValue<Stream>
  3. TdParameter.GetValue<Stream>

See Also

Data Type Mappings

Accessor Methods for Retrieving Data

Configuring Parameters and Parameter Data Types