Send feedback on this topic.
Teradata.Client.Provider
TdIntervalHourToMinute Structure
Members  Example 



Teradata.Client.Provider Namespace : TdIntervalHourToMinute Structure
TdIntervalHourToMinute represents an interval of time defining a duration in hours and minutes. The hour precision is configurable.
Object Model
TdIntervalHourToMinute StructureTdIntervalHourToMinute StructureTdIntervalHourToMinute StructureTdIntervalHourToMinute StructureTdIntervalHourToMinute StructureTdIntervalHourToMinute Structure
Syntax
Remarks

TdIntervalHourToMinute is a .NET Data Provider for Teradata specific type, designed to support a SQL Interval Hour To Minute data type.

The TdIntervalHourToMinute supports the Teradata Interval Hour (precision) To Minute data type where precision indicates the number of digits in the hours (from 1 - 4).

The interval value must be specified in the following format :

[sign][hours]:[mm].

Below is the description of each format item.

Format Item Description
sign Optional - . Defaults as space character (+).
hours Required number of hours from 0 - 9999.
mm Required number of minutes from 00 - 59.

.NET does not have a system type that directly corresponds to the SQL Interval Hour To Minute data type. The .NET Data Provider for Teradata Version 13.0 version and prior versions map Interval Hour To Minute to System.String. With version 13.1 of the provider, TdIntervalHourToMinute is available to retrieve and manipulate data of type Interval Hour To Minute.

The range of values for the TdIntervalHourToMinute with hour precision values of 1 - 4 is as follows:

Type and Precision

Minimum

Maximum

TdIntervalHourToMinute(1)

-'9:59'

'9:59'
TdIntervalHourToMinute(2)

-'99:59'

'99:59:'
TdIntervalHourToMinute(3)

-'999:59'

'999:59'
TdIntervalHourToMinute(4)

-'9999:59'

'9999:59'

TdIntervalHourToMinute also supports TdIntervalHourToMinute.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 TdIntervalHourToMinute structure allows arithmetic, comparision and conversion operations to be performed.

A TdIntervalHourToMinute 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 TdIntervalHourToMinute. 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 Hour To Minute data type please see the 'SQL Data Types and Literals' manual.

Example

The following example shows how to retrieve a TdIntervalHourToMinute, modify the interval, and then update the table.

Public void IntervalExample(TdCommand cmd, String client)
{
   cmd.Parameters.Clear();
   
   cmd.CommandText = "SELECT StartDate, AppointmentStart, DelayPeriod " +
                     "FROM Appointments " +
                     "WHERE Client = ?";
 
   cmd.CommandType = CommandType.Text;
 
   cmd.Parameters.Add(null, TdType.VarChar, 10,
        ParameterDirection.Input, true, 0, 0, null,    
        DataRowVersion.Default, client);
 
   Int32 row = 0;
   TdDate [] startDate;
   TdTimestamp [] appointmentStart;
   TdIntervalHourToMinute [] appointmentLength;
   
   using (TdDataReader dr = cmd.ExecuteReader())
   {
      startDate = new TdDate[dr.RecordsReturned];
      appointmentStart = new TdTimestamp[dr.RecordsReturned];
      appointmentLength = new TdIntervalHourToMinute [dr.RecordsReturned];
 
      // Specifying an interval of 1 hour, 30 minutes with an hour precision of 2
      TdIntervalHourToMinute AppointmentExtension = new TdIntervalHourToMinute(1, 30, 2);
   
      while (dr.Read())
      {
         // Retrieving the dates
         startDate[row] = dr.GetTdDate(0);
         appointmentStart[row] = dr.GetTimestamp(1);
         appointmentLength[row] = dr.GetTdIntervalHourToMinute(2);
 
         // Adding extension to the lease return
         appointmentStart[row] = appointmentStart[row] + AppointmentExtension;
 
         // Adding extension to the lease length;
         appointmentLength[row] = appointmentLength[row] + AppointmentExtension;
 
         row++;
      } 
   }
 
   cmd.Parameters.Clear();
 
   cmd.CommandText = "UPDATE Appointments " +
                     "SET AppointmentStart = ?, DelayPeriod = ? " +
                     "WHERE Client = ?";
 
   cmd.Parameters.Add(null, TdType.Timestamp, 0,
         ParameterDirection.Input, true, 0, 0, null,    
         DataRowVersion.Default, null);
 
   cmd.Parameters.Add(null, TdType.IntervalHourToMinute, 0,
         ParameterDirection.Input, true, 0, 0, null,    
         DataRowVersion.Default, null);
 
   cmd.Parameters.Add(null, TdType.VarChar, 9,
         ParameterDirection.Input, true, 0, 0, null,    
         DataRowVersion.Default, model);
 
   row--;
   while(row >= 0)
   {
      cmd.Parameters[0].Value = appointmentStart[row];
      cmd.Parameters[1].Value = appointmentLength[row];
      cmd.Parameters[2].Value = model;
 
      cmd.ExecuteNonQuery();
      row--;
   }
}
Inheritance Hierarchy

System.Object
   System.ValueType
      Teradata.Client.Provider.TdIntervalHourToMinute

Requirements

Target Platforms: Windows 8.1, Windows 10, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019

See Also

Reference

TdIntervalHourToMinute Members
Teradata.Client.Provider Namespace
EnableTdIntervals Property
Interval Connection String Attribute
Enabling Provider Specific Types
Provider Specific Type: Interval Type Overview