.Net TeraData.Client.Provider 13.0.0.0 TdTime

Tools

.Net TeraData.Client.Provider 13.0.0.0 TdTime

When I run a query using the TdCommand.ExcuteReader I am getting back an Integer when the type should be TdTime. The data type on the field in question is time within the TeraData DB. I have also set "Enable TdDateTime = true;" in the connection string. Please advise.
7 REPLIES

Re: .Net TeraData.Client.Provider 13.0.0.0 TdTime

Do you still have this question? If so, please tell me what method you are calling in the TdDataReader to obtain the data. When you set the EnableTdDateTime attribute, the GetProviderSpecificValue will return the data as the TdTime. Otherwise the data will be returned as a TimeSpan (old behavior as an FCL type). If you know the value is a TdTime, then you can call TdDataReader.GetTdTime(Int32 ordinal).

Re: .Net TeraData.Client.Provider 13.0.0.0 TdTime

Type t = dr.GetProviderSpecificFieldType(i);

if (t == typeof(TdDate)) {.......}
else if (t == typeof(TdTime)) {.......}

the second never gets called. When it should come back as time it comes back as integer. I have a workaround that is not too pretty but works for now. I dont have access to change the table structures but when I look at the datatype for the columns in question it is set as Time. So the .net dataprovider is not recoginising the column as Time

Re: .Net TeraData.Client.Provider 13.0.0.0 TdTime

I suspect that maybe you have the wrong ordinal. Try this

Int32 colOrdinal = reader.GetOrdinal("column name");
Type tdtype = reader.GetProviderSpecificFieldType(colOrdinal);
Type fieldtype = reader.GetFieldType(colOrdinal);

Substitute the column name for the Time column in GetOrdinal() and you should see that tdtype == typeof(TdTime) and fieldType == typeof (TimeSpan) if you have EnableDateTime set to true.

Re: .Net TeraData.Client.Provider 13.0.0.0 TdTime



How does that differ from this

for (int i = 0; i < dr.FieldCount; i++)
{
Type t = dr.GetProviderSpecificFieldType(i);
if (t == typeof(TdDate))
{
TdDate dt = dr.GetTdDate(i);
}
else if (t == typeof(TdDate))
{
TdTime time = dr.GetTdTime(i);
}
}
Teradata Employee

Re: .Net TeraData.Client.Provider 13.0.0.0 TdTime

I suggest using NQUERY to look at the SchemaTable (TdDataReader.GetSchemaTable) for the query in question.
NQuery is in InstallDirectory\Samples\Bin directory; Right-Click in "Results" window and select "View result schema".

In some cases Teradata Database does not return a TIME data type. For example "SELECT TIME" will return DOUBLE with format "99:99:99". In this case Provider will return a System.Double for ProviderSpecificValue.

Re: .Net TeraData.Client.Provider 13.0.0.0 TdTime

Yeah it has a dattype of Int32 when I look at the result schema. It has a format property set to 99:99:99 but the value comes back as an Integer. Oh well I guess there is nothing I can do since I do not have control over the database.
Teradata Employee

Re: .Net TeraData.Client.Provider 13.0.0.0 TdTime

Try this

select cast(CAST(TIME as char(10)) as time(0))

It will force database to return a TIME data type.