The Schema collections return metadata for the Teradata Database objects. The notable metadata columns for the Interval Month data type are:
Column Name | Description |
---|---|
COLUMN_TYPE or DATA_TYPE |
Set to INTERVAL MONTH. |
FORMAT | Teradata Database Format assigned to the Teradata Database object. |
PROVIDERDBTYPE | It is set to TdType.IntervalMonth. |
INTERVAL_PRECISION | The maximum number of digits for the Month component. |
The TdDataReader.SchemaTable returns result set metadata. The notable metadata columns for the Interval Month data type are:
Column Name | Description |
---|---|
NumericPrecision | The maximum number of digits for the Month component. |
DataType | System.Type object for the System.String class. |
ProviderType | Set to TdType.IntervalMonth. |
Format | Teradata Database Format assigned to the Teradata Database object. |
ProviderSpecificDataType | System.Type object for the TdIntervalMonth structure. |
The following example shows how to configure an Interval Month parameter using DbType type declaration and a Base Class Library (BCL) value.
![]() |
---|
The Data Provider sends a VarChar data type to the Teradata Database when TdParameter.DbType is set to DbType.String. The Teradata Database will perform an implicit conversion to the Interval Month data type when required. The Teradata Database "SQL Functions, Operators, Expressions and Predicates" manual documents all implicit and explicit Data Type conversions. |
C# |
Copy Code
|
---|---|
TdParameter deliveryInterval = new TdParameter(); deliveryInterval.ParameterName = "deliveryMonths"; deliveryInterval.DbType = DbType.String; // DBS will perform implicit conversion. deliveryInterval.Value = " 9"; |
The following example shows how to configure an Interval Month parameter using TdType type declaration and a Provider Specific value. The TdParameter.Precision property reflects the maximum number of digits for the Year component and it must be equal to or less than the target Teradata Database object (i.e. Column, Expression, Stored Procedure Parameters and etc.) declaration. The range of values are from One to Four. It is recommend to always set TdParameter.Precision property, however the Data Provider will utilize TdIntervalMonth.Precision property value when the TdParameter.Precision property is set to zero. .NET Applications can retrieve metadata from the Schema Collections or the Schema Table and apply the metadata to the TdParameter object.
![]() |
---|
The Data Provider will throw an exception if the Interval value is greater than the maximum permissible value specified by the TdParameter.Precision property. |
C# |
Copy Code
|
---|---|
TdParameter deliveryInterval = new TdParameter(); deliveryInterval.ParameterName = "deliveryMonths"; deliveryInterval.TdType = TdType.IntervalMonth; // Maximum number of digits for the Month component deliveryInterval.Precision = 2; deliveryInterval.ProviderSpecificValue = new TdIntervalMonth(9); |
The syntax for the Interval Month Literal is INTERVALsign'dddd'MONTH. Interval Month literals consist of the word Interval followed by optional negative sign, character string literal representation of the number of months (up to 4 digits) and the word Month.
![]() |
---|
We recommend to always use Parameters in order to take advantage of the Teradata Database Request Cache. |
The following example shows 10 Months represented as Interval Month 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(); // Delivery exceeding 10 months. cmd.CommandText = "SELECT Id, orderDate from Order where ((CURRENT_DATE - OrderDate) MONTH) > INTERVAL'10'MONTH "; using (TdDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { Console.WriteLine("Id={0}", reader.GetInt64(0).ToString()); } } } } |
The following methods and properties return the column or parameter value as a System.String structure.
The following methods and properties return the column or parameter value as a TdIntervalMonth structure.
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, orderDate, deliveryMonths from Order where deliveryMonths > ?"; cmd.Parameters.Add("deliveryMonthss", TdType.IntervalMonth); cmd.Parameters[0].Precison = 2; cmd.Parameters[0].Value = new TdIntervalMonth(2); using (TdDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { Console.WriteLine("[String] Delivery Months = {0}", reader.GetString(2)); Console.WriteLine("[TdIntervalMonth] Delivery Months = {0}", reader.GetTdIntervalMonth(2).ToString()); } } } } /* Output: [String] Delivery Months = 3 [TdIntervalMonth] Delivery Months = 3 */ |
Accessor Methods for Retrieving Data
Configuring Parameters and Parameter Data Types