In earlier releases of the provider a Teradata data type was mapped to a .NET Class Library (FCL) type (e.g. Int32, DateTime, TimeSpan, String) that matched the Teradata data type's capabilities. This FCL type was then used by an application to send and receive data from the Advanced SQL Engine. However, in some cases the FCL type does not contain the same behaviors or capabilities as that of the corresponding Teradata data type.
Provider specific types have been introduced so that applications can use similar capabilities as those provided by the corresponding Teradata data type. However, applications that were developed using earlier versions of the provider may experience backward compatibility issues if the provider type were to completely replace the FCL type. These issues are described in the following sections:
To resolve the backward compatibility issues, there is an ENABLE connection string attribute for each provider specific type that contains these backward compatibility issues. These attributes affect the behavior of the following provider objects:
These attributes affect the behavior of methods and properties that return the data or information about provider specific types. When the ENABLE attribute is set to true, the corresponding provider type is used. When set to false, the FCL type originally supported by the provider is used.
The following is a chart that shows the ENABLE connection string attributes and the corresponding provider specific types:
The backward compatibility issue occurs when an application uses TdDataAdapter to fill a DataTable. In earlier releases of the provider, before a particular provider specific type was introduced, the mapped FCL type was used to fill the DataTable.
To control whether a provider specific type is used to fill a DataTable, the property DataAdapter.ReturnProviderSpecificTypes is used. By default this property is set to false. By using this property and the connection string attribute, a DataTable will be filled using the provider specific type under the following scenarios:
ReturnProviderSpecificTypes | ENABLE Connection String Attribute | Provider Specific Type Used? |
true | true | yes |
true | false | no |
false | true | no |
false | false | no |
The TdDataReader is only affected by provider specific types when retrieving data of a column whose data type is mapped to a provider type. For example, the Teradata type Date is mapped to the provider type TdDate. However, for versions that do not have support for TdDate, the Teradata type Date is mapped to the FCL type DateTime.
The re-mapping of the Teradata data type only affects three TdDataReader methods:
If the original behavior of these methods and properties is required, an application will need to set the corresponding ENABLE connection string attribute to false. This will cause these methods to return data as the FCL type that was originally mapped to the Teradata data type. If the attribute is set to true, data of the provider specific type will be returned.
Any behavioral changes associated with provider specific types and the ENABLE connection string attributes will only be felt by an application after a stored procedure that contains inputoutput and/or output parameters is executed.
The use of a provider specific type and the ENABLE attribute will affect the behavior of the TdParameter.ProviderSpecificValue property. The data type that is returned when this property is accessed is dependent upon on how the ENABLE attribute was set.
The TdParameter.Value propery is not affected by this attribute. However, after the execution of a stored procedure, this property will only return the FCL type representation of the data of the output and inputoutput parameters.
The behavior of the TdParameter.ProviderSpecificValue is different before the execution of a stored procedure that contains inputoutput and/or output parameters and after execution. Before the stored procedure is executed, the behavior of ProviderSpecificValue is to return the data as a provider type. At this point, the ENABLE connection string attribute is ignored. For example, suppose an application has established a connection but has not executed a stored procedure that contains an input-output parameter. The TdParameter.Value has also been set to a value that is of a System.DateTime type and the Parameter.TdType is set to TdType.Date. When the TdParameter.ProviderSpecificValue is accessed, a TdDate will be returned.
After the stored procedure has been executed, the setting of the ENABLE connection string attributes will affect the behavior of the TdParameter.ProviderSpecificValue property. The setting of the attribute will affect the type (FCL or Provider) that is used to represent the data that is returned when an application accesses this property.
The following table describes the type that will be returned from TdParameter.ProviderSpecificValue that is associated with an inputoutput and output parameter before and after the execution of a stored procedure. The initial setting of the Value property is also shown. This only applies to Teradata data types that have a corresponding provider specific type.
Enable connection String Attribute |
Application specified Input Parameter Value |
Parameter Direction | ProviderSpecificValue Before Execution |
ProviderSpecificValue After Execution |
true | FCL type | Input | Provider Type | Provider Type |
InputOutput | Provider Type | Provider Type | ||
Output | null | Provider Type | ||
true | Provider Type | Input | Provider Type | Provider Type |
IntputOutput | Provider Type | Provider Type | ||
Output | null | Provider Type | ||
false | FCL Type | Input | Provider Type | Provider type |
IntputOutput | Provider Type | FCL Type | ||
Output | null | FCL Type | ||
false | Provider Type | Input | Provider Type | Provider type |
IntputOutput | Provider Type | FCL Type | ||
Output | null | FCL Type |
The following example demonstrates the effect of the EnableTdDateTime attribute before and after a stored procedure has been executed.
C# |
Copy Code |
---|---|
TdConnection cn = new TdConnection("Data Source=tdat;EnableTdDateTime=false;User Id=tuser; Password=tuser"); cn.Open(); TdCommand cmd = cn.CreateCommand(); cmd.Parameters.Add(null, TdType.Date, 0, ParameterDirection.InputOutput, true, 0, 0, null, DataRowVersion.Default, new DateTime(2008, 12, 10)); // The output to the console will be "TdDate". The behavior of ProviderSpecificValue // before the execution of the stored procedure is to return the provider specific type. Console.Writeln(cmd.Parameters[0].ProviderSpecificValue.GetType().Name); // Execute stored procedure that accepts an inputoutput parameter cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "StoreProcedureOneInputOutputParam"; cmd.ExecuteNonQuery(); // Now when the ProviderSpecificValue property is accessed the type that it contains // is a DateTime type. The reason for this is that the connection string attribute // EnableTdDateTime has been set to false in the connection string. In this situation // the behavior of ProviderSpecificValue is to return the FCL type. Console.Writeln(cmd.Parameters[0].ProviderSpecificValue.GetType().Name); |
The TdParameter.Value property is not affected by the ENABLE connection string attribute. When an application accesses the Value property of an output or inputoutput parameter after the execution of a stored procedure, the FCL type representation of the data will always be returned.
Note |
---|
The data that is returned from the Value property of inpoutoutput parameters will be represented by an FCL type even though the parameter was initially set to a provider specific type. |
For example, suppose a stored procedure contains an inputoutput parameter and that an application has set the Value property of the TdParameter that corresponds to this stored procedure parameter to a TdDecimal. Before the stored procedure has been executed, the application can retrieve the data from Value as a TdDecimal. After the stored procedure has been executed, the provider sets Value as the corresponding FCL type to TdDecimal which is System.Decimal. The application can now only access this data as a System.Decimal.