Send feedback on this topic.
Teradata.Client.Provider
TdParameter Class
Members  Example 



Teradata.Client.Provider Namespace : TdParameter Class
Represents a parameter to a SQL statement.
Syntax
'Declaration
 
Public NotInheritable Class TdParameter 
   Inherits System.Data.Common.DbParameter
   Implements System.Data.IDataParameterSystem.Data.IDbDataParameterSystem.ICloneable 
'Usage
 
Dim instance As TdParameter
Remarks

Parameterized SQL statements accept one or more input parameters (data). TdParameter represents the data value and can be associated with TdCommand objects using TdCommand.Parameters property. TdParameter describes the .NET data type and the corresponding Teradata column type. The data provider converts .NET data types to SQL data types before it is sent to the Advanced SQL Engine for processing. The data provider cannot derive parameter data type information from Teradata when the TdCommand is prepared. Therefore, the data provider relies on information provided by the TdParameter object or it implicitly maps the .NET data type to Teradata data type.

Teradata Stored Procedures also support output and input-output parameters. TdParameter can correctly map .NET data types to Teradata data types and back and therefore fully support Input, Input-Output and Output parameters to SQL statements.

The data provider does not support the USING CLAUSE. All SQL statements should use parameter markers (Question Mark) as oppose to USING CLAUSE and parameter names prefixed with the colon character.

It is highly recommended to use parameterized queries in order to take advantage of the Teradata Statement-Cache. See the Teradata SQL manual for additional information.

For information on how to specify a LOB as a parameter please refer to TdParameter.Value

Example
The following example inserts a row into the Order table. TdParameter objects corresponding to the columns in Order table are added to the Parameters collection (TdParameterCollection) of the TdCommand object before it is executed using TdCommand.ExecuteNonQuery.
public void InsertOrder(TdConnection cn, String orderId, 
                        String customerId, DateTime orderDate)
{
    TdCommand cmd = new TdCommand("Insert Into Order (OrderID, CustomerID, " + 
                                  "OrderDate) Values (?, ?, ?)",
                                  cn);
            
    cmd.Parameters.Add("orderId", TdType.Char, 15);
    cmd.Parameters.Add("customerId", TdType.Char, 10);
    cmd.Parameters.Add("orderDate", TdType.Date);
            
    cmd.Parameters["orderId"].Value = orderId;
    cmd.Parameters["customerId"].Value = customerId;
    cmd.Parameters["orderDate"].Value = orderDate;
            
    cmd.ExecuteNonQuery();
}
Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.Data.Common.DbParameter
         Teradata.Client.Provider.TdParameter

Requirements

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

See Also

Reference

TdParameter Members
Teradata.Client.Provider Namespace