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

Schema Collections

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

Column Name Description

COLUMN_TYPE

or

DATA_TYPE

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

Schema Table

The TdDataReader.SchemaTable returns result set metadata. The notable metadata columns for the Blob 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.Blob.
Format Format assigned to the SQL Engine object.
ProviderSpecificDataType System.Type object for the TdBlob class.

Configuring Parameters

The following example shows how to configure a Blob parameter using DbType type declaration, Size property and a BCL value.

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

customerPicture.DbType = DbType.Binary;
customerPicture.Size = 64001;

customerPicture.Value = customerPictureBuffer;
Note

The Data Provider maps DbType.Binary to the SQL Engine VarByte Data Type when Size is less than or equal to 64,000 Bytes. The Data Provider maps DbType.Binary to the SQL Engine BLOB Data Type when Size is greater than 64,000.

The following example shows how to configure a Blob parameter using TdType type declaration and a BCL value.

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

customerPicture.TdType = TdType.Clob;

customerPicture.Value = customerPictureBuffer;

The TdParameter.Value should be set to an Array of Bytes (Char[]) or an instance of System.IO.Stream.

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.

Retrieving Blob Data

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

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

The following methods and properties return the column or parameter value as a TdBlob class.

Note

The CommandBehavior (see TdCommand.ExecuteReader(CommandBehavior)) must not include CommandBehavior.SequentialAccess.

  1. TdDataReader.GetTdBlob
  2. TdDataReader.GetProviderSpecificValue
  3. TdDataReader.GetFieldValue<TdBlob>
  4. TdParameter.ProviderSpecificValue
  5. TdParameter.GetValue<TdBlob>

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

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

The CommandBehavior.SequentialAccess can potentially result in best overall performance. However in this mode BLOB data type cannot be transformed to TdBlob or Stream class. The CommandBehavior.SequentialAccess reduces the overall messages between the Data Provider and the SQL Engine because LOBs are transmitted to the Data Provider in Inline-mode.

See Also

Data Type Mappings

Accessor Methods for Retrieving Data

Configuring Parameters and Parameter Data Types

Large Object (LOB) Data Types