The Schema collections return metadata for the Teradata Database objects. The notable metadata columns for the Interval Second data type are:
Column Name | Description |
---|---|
COLUMN_TYPE or DATA_TYPE |
Set to INTERVAL SECOND. |
FORMAT | Teradata Database Format assigned to the Teradata Database object. |
PROVIDERDBTYPE | It is set to TdType.IntervalSecond. |
DATETIME_PRECISION | The maximum number of digits for the fractional-second component. |
INTERVAL_PRECISION | The maximum number of digits for the Second component. |
The TdDataReader.SchemaTable returns result set metadata. The notable metadata columns for the Interval Second data type are:
Column Name | Description |
---|---|
NumericPrecision | The maximum number of digits for the Second component. |
NumericScale | The maximum number of digits for the fractional-second component. |
DataType | System.Type object for the System.TimeSpan structure. |
ProviderType | Set to TdType.IntervalSecond. |
Format | Teradata Database Format assigned to the Teradata Database object. |
ProviderSpecificDataType | System.Type object for the TdIntervalSecond structure. |
The following example shows how to configure an Interval Second parameter using DbType type declaration and a Base Class Library (BCL) value. The TdParameter.Precision property reflects the maximum number of digits for the Second 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. The TdParameter.Scale property reflects the maximum number of digits for the fractional-second 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 Data Provider will throw an exception if the TotalSeconds property of the System.TimeSpan value is greater than 9,999 Seconds. |
![]() |
---|
The Data Provider truncates the fractional seconds to the Scale specified. |
C# |
Copy Code
|
---|---|
TdParameter deliveryInterval = new TdParameter(); deliveryInterval.ParameterName = "deliverySeconds"; deliveryInterval.DbType = DbType.Object; // Maximum number of digits for the Second component deliveryInterval.Precision = 2; // Maximum number of Fractional-Second digits deliveryInterval.Scale = 3; // 3 seconds and 10 milliseconds. deliveryInterval.Value = new System.TimeSpan(0, 0, 0, 3, 10); |
The following example shows how to configure an Interval Second parameter using TdType type declaration and a Provider Specific value. It is recommend to always set TdParameter.Precision and TdParameter.Scale properties, however the Data Provider will utilize TdIntervalSecond.Precision and TdIntervalSecond.Scale property values when the TdParameter.Precision and TdParameter.Scale properties are 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 Second component is greater than the maximum permissible value specified by the TdParameter.Precision property. |
![]() |
---|
The Data Provider truncates the fractional seconds to the TdParameter.Scale specified. |
C# |
Copy Code
|
---|---|
TdParameter deliveryInterval = new TdParameter(); deliveryInterval.ParameterName = "deliverySecond"; deliveryInterval.TdType = TdType.IntervalSecond; // Maximum number of digits for the Second component deliveryInterval.Precision = 2; // Maximum number of digits for the Fractional-Second component deliveryInterval.Scale = 6; // 3 seconds and 10 microseconds . deliveryInterval.ProviderSpecificValue = new TdIntervalSecond(3, 10); |
The syntax for the Interval Second Literal is INTERVALsign'ssss.ffffff'SECOND. Interval Second literals consist of the word Interval followed by an optional negative sign, character string literal representation of the number of Seconds (up to 4 digits ranging from 0 to 9999) and Fractional-Seconds (up to 6 digits ranging from 0 to 999999) and the word Second.
![]() |
---|
We recommend to always use Parameters in order to take advantage of the Teradata Database Request Cache. |
The following example shows 759 seconds and 10 milliseconds represented as Interval Second 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 759 seconds and 10 milliseconds. cmd.CommandText = "SELECT Id, orderDate from Order where (CURRENT_TIMESTAMP - OrderTS) > INTERVAL'759.010'SECOND "; 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.TimeSpan structure.
The following methods and properties return the column or parameter value as a TdIntervalSecond 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, deliverySeconds from Order where deliverySeconds > ?"; cmd.Parameters.Add("delivery", TdType.IntervalSecond); cmd.Parameters[0].Precison = 2; cmd.Parameters[0].Scale = 3; cmd.Parameters[0].Value = new TimeSpan(0, 0, 0, 3, 10); using (TdDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { Console.WriteLine("[TimeSpan] Delivery Second = {0}", reader.GetValue(2).ToString()); Console.WriteLine("[TdIntervalSecond] Delivery Second = {0}", reader.GetTdIntervalSecond(2).ToString()); } } } } /* Output: [TimeSpan] Delivery Minute to Seconds = 00:00:09.0000000 [TdIntervalSecond] Delivery Second = 9.000 */ |
Accessor Methods for Retrieving Data
Configuring Parameters and Parameter Data Types