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

Schema Collections

The Schema collections return metadata for the Teradata Database objects. The notable metadata columns for the Integer data type are:

Column Name Description

COLUMN_TYPE

or

DATA_TYPE

Set to INTEGER.
NUMERIC_PRECISION Set to 10.
FORMAT Teradata Database Format assigned to the Teradata Database object.
PROVIDERDBTYPE It is set to TdType.Integer.

Schema Table

The TdDataReader.GetSchemaTable returns result set metadata. The notable metadata columns for the Integer data type are:

Column Name Description
NumericPrecision Set to 10.
DataType System.Type object for the System.Int32 type.
ProviderType Set to TdType.Integer.
Format Teradata Database Format assigned to the Teradata Database object.
ProviderSpecificDataType

System.Type object for the System.Int32 structure.

Note

The Data Provider does not have a Provider Specific Type corresponding to the Integer data type. The Data Provider returns System.Int32 data type from the Provider Specific Value methods.

Configuring Parameters

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

C#
Copy Code
TdParameter quantity = new TdParameter();

quantity.DbType = DbType.Int32;

quantity.Value = 33000;

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

C#
Copy Code
TdParameter quantity = new TdParameter();

quantity.TdType = TdType.Integer;

quantity.Value = 33000;

Specifying Integer as Literal

The syntax for the Integer Literal ±dddddddddd. Integer literals consist of an optional sign (+ or -) followed by five to ten digits. Integer values ranging from -2147483648 to -32769 and 32768 to 2147483647 are considered an Integer data type value.

Note

We recommend to always use Parameters in order to take advantage of the Teradata Database Request Cache.

The following example shows 33,000 represented as Integer-Literal in the Command Text.

C#
Copy Code
using (TdConnection cn = new TdConnection("data source=x;UserId=y;Password=z;"))
{
    cn.Open();
    TdCommand cmd = cn.CreateCommand();

    cmd.CommandText = "SELECT Id, orderDate from Order where quantity > 33000  ";

    using (TdDataReader reader = cmd.ExecuteReader())
    {
        if (reader.HasRows)
        {
            while (reader.Read())
            {
                Console.WriteLine("Id={0}, orderDate={1}", reader.GetInt64(0), reader.GetDate(1));
            }
        }
    }
}

Retrieving Integer Data

The following methods and properties return the column or parameter value as a System.Int32 structure.

  1. TdDataReader.GetInt32
  2. TdDataReader.GetValue
  3. TdDataReader.GetFieldValue<Int32>
  4. TdParameter.Value
  5. TdParameter.GetValue<Int32>

The following Provider Specific Value method and property return the column or parameter value as a System.Int32 structure.

Note

The Data Provider does not have a Provider Specific Type corresponding to the Integer data type. The Data Provider returns System.Int32 data type from the Provider Specific Value methods.

  1. TdDataReader.GetProviderSpecificValue
  2. TdParameter.ProviderSpecificValue
C#
Copy Code
using (TdConnection cn = new TdConnection("data source=DS1;UserId=Joe;Password=XY;"))
{
    cn.Open();

    TdCommand cmd = cn.CreateCommand();
    cmd.CommandText = "SELECT Id, Quantity from Order where Quantity > ?";
    cmd.Parameters.Add("quantity", TdType.Integer);
    cmd.Parameters["quantity"].Value = 33000;

    using (TdDataReader reader = cmd.ExecuteReader())
    {
        if (reader.HasRows)
        {
            while (reader.Read())
            {
                Console.WriteLine("[System.Int32] Quantity = {0}", reader.GetInt32(1).ToString());
            }
        }
    }
}

/* Output:
    [System.Int32] Quantity = 33099
*/

See Also

Data Type Mappings

Accessor Methods for Retrieving Data

Configuring Parameters and Parameter Data Types