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

Schema Collections

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

Column Name Description

COLUMN_TYPE

or

DATA_TYPE

Set to BYTE.
CHARACTER_OCTET_LENGTH Returns length of the column in Bytes.
PROVIDERDBTYPE It is set to TdType.Byte.

Schema Table

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

Column Name Description
ColumnSize Returns length of the column in Bytes.
DataType System.Type object for the System.Byte[] type.
ProviderType Set to TdType.Byte.
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 Byte 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.Byte;

customerPicture.Value = pictureBuffer;

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

Note

The Data Provider will zero-fill the data when the length of the input parameter value is less than the TdParameter.Size property value.

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 number of Bytes the Data Provider will send to the SQL Engine and/or 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 Byte as Literal

The syntax for the BYTE Literal is 'hexadecimal digits'XBF. For example 'C1C0'XBF declares a BYTE(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 Byte 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 methods return the column or parameter 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