
'Declaration Public Structure TdIntervalSecond Inherits System.ValueType Implements System.Data.SqlTypes.INullable, System.IComparable, System.IComparable(Of TdIntervalSecond), System.IConvertible, System.IEquatable(Of TdIntervalSecond), System.IFormattable, System.Xml.Serialization.IXmlSerializable
'Usage Dim instance As TdIntervalSecond
public struct TdIntervalSecond : System.ValueType, System.Data.SqlTypes.INullable, System.IComparable, System.IComparable<TdIntervalSecond>, System.IConvertible, System.IEquatable<TdIntervalSecond>, System.IFormattable, System.Xml.Serialization.IXmlSerializable
public value class TdIntervalSecond : public System.ValueType, System.Data.SqlTypes.INullable, System.IComparable, System.IComparable<TdIntervalSecond>, System.IConvertible, System.IEquatable<TdIntervalSecond>, System.IFormattable, System.Xml.Serialization.IXmlSerializable
TdIntervalSecond is a .NET Data Provider for Teradata specific type, designed to support a SQL Interval Second data type.
The TdIntervalSecond supports the Teradata Interval Second (precision, scale) data type where precision indicates the number of digits in the seconds (from 1 - 4) and scale indicates the fractional precision for the values of seconds. The scale may range from 0 to 6.
The interval value must be specified in the following format :
[sign][seconds].[ffffff]
Below is the description of each format item.
Format Item | Description |
---|---|
sign | Optional - . Defaults as space character (+). |
seconds | Required number of seconds (one to four digits in length). |
ffffff | Optionally the number of fractional seconds (0 to 6 digits in length). |
.NET does not have a system type that directly corresponds to the SQL Interval Second data type. The .NET Data Provider for Teradata Version 13.0 version and prior versions map Interval Second to System.String. With version 13.1 of the provider, TdIntervalSecond is available to retrieve and manipulate data of type Interval Second.
The range of values for the TdIntervalSecond containing a second precision of 1 is as follows:
Second Precision | Second Scale |
Minimum |
Maximum |
---|---|---|---|
1 | 0 |
-'9' |
'9' |
1 | 1 |
-'9.9' |
'9.9' |
1 | 2 |
-'9.99' |
'9.99' |
1 | 3 |
-'9.999' |
'9.999' |
1 | 4 |
-'9.9999' |
'9.9999' |
1 | 5 |
-'9.99999' |
'9.99999' |
1 | 6 |
-'9.999999' |
'9.999999' |
The range of values for second precision values of 2,3 and 4 all follow the same pattern. For completeness, the following chart displays the range of values for a TdIntervalSecond with a second precision of 4.
Second Precision |
Second Scale |
Minimum |
Maximum |
---|---|---|---|
4 | 0 |
-'9999' |
'9999' |
4 | 1 |
-'9999.9' |
'9999.9' |
4 | 2 |
-'9999.99' |
'9999.99' |
4 | 3 |
-'9999.999' |
'9999.999' |
4 | 4 |
-'9999.9999' |
'9999.9999' |
4 | 5 |
-'9999.99999' |
'9999.99999' |
4 | 6 |
-'9999.999999' |
'9999.999999' |
TdIntervalSecond also supports TdIntervalSecond.Null. This is a very important feature. An application is no longer required to call TdDataReader.IsDBNull before invoking the corresponding TdDataReader "Get" method. This will improve overall performance.
A TdIntervalSecond structure allows arithmetic, comparision and conversion operations to be performed.
A TdIntervalSecond may also be specified as an in, out, or in/out parameter to a stored procedure. In order to maintain backward compatibility with previous versions of the provider (release 13.0 and prior), a Connection String Attribute TdConnectionStringBuilder.EnableTdIntervals has been added. When the EnableTdIntervals attribute is true
, TdParameter.ProviderSpecificValue will return the data as the provider specific type of TdIntervalSecond. When EnableTdIntervals is false
, TdParameter.ProviderSpecificValue will return the data as a .NET Framework Library data type of String.
The TdParameter.Value will also return the .NET Framework Library data type of System.String when EnableTdIntervals is false
to maintain backward compatibility. The TdParameter.Value will return a .NET Framework data type of TimeSpan when EnableTdIntervals is true
.
For more information on the Teradata Interval Second data type please see the 'SQL Data Types and Literals' manual.
The following example shows how to retrieve a TdIntervalSecond, modify the interval, and then update the table.
Public void IntervalExample(TdCommand cmd, Int32 task) { cmd.Parameters.Clear(); cmd.CommandText = "SELECT StartDate, StartTime, TaskLen " + "FROM Schedule " + "WHERE Task = ?"; cmd.CommandType = CommandType.Text; cmd.Parameters.Add(null, TdType.Integer, 4, ParameterDirection.Input, true, 0, 0, null, DataRowVersion.Default, task); Int32 row = 0; TdDate [] startDate; TdTimestamp [] startTime; TdIntervalSecond [] taskLen; using (TdDataReader dr = cmd.ExecuteReader()) { startDate = new TdDate[dr.RecordsReturned]; startTime = new TdTimestamp[dr.RecordsReturned]; taskLen = new TdIntervalSecond [dr.RecordsReturned]; // Specifying an interval of 2 hours, 5 minutes // with an second precision of 4 and scale of 0 TdIntervalSecond leaseReturnExtension = new TdIntervalSecond(7500, 0, 4, 0); while (dr.Read()) { // Retrieving the dates startDate[row] = dr.GetTdDate(0); startTime[row] = dr.GetTimestamp(1); taskLen[row] = dr.GetTdIntervalSecond(2); // Adding extension to the lease return startTime[row] = startTime[row] + leaseReturnExtension; // Adding extension to the lease length; taskLen[row] = taskLen[row] + leaseReturnExtension; row++; } } cmd.Parameters.Clear(); cmd.CommandText = "UPDATE Schedule " + "SET StartTime = ?, TaskLen = ? " + "WHERE Task = ?"; cmd.Parameters.Add(null, TdType.Timestamp, 0, ParameterDirection.Input, true, 0, 0, null, DataRowVersion.Default, null); cmd.Parameters.Add(null, TdType.IntervalSecond, 0, ParameterDirection.Input, true, 0, 0, null, DataRowVersion.Default, null); cmd.Parameters.Add(null, TdType.Integer, 4, ParameterDirection.Input, true, 0, 0, null, DataRowVersion.Default, task); row--; while(row >= 0) { cmd.Parameters[0].Value = startTime[row]; cmd.Parameters[1].Value = taskLen[row]; cmd.Parameters[2].Value = task; cmd.ExecuteNonQuery(); row--; } }
System.Object
System.ValueType
Teradata.Client.Provider.TdIntervalSecond
Target Platforms: Windows 8.1, Windows 10, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019
TdIntervalSecond Members
Teradata.Client.Provider Namespace
EnableTdIntervals Property
Interval Connection String Attribute
Enabling Provider Specific Types
Provider Specific Type: Interval Type Overview