Send feedback on this topic.
Teradata.Client.Provider
Value Property (TdParameter)
Example 



Teradata.Client.Provider Namespace > TdParameter Class : Value Property
Gets or sets the value of the TdParameter object.
Syntax
'Declaration
 
Public Overrides NotOverridable Property Value As Object
'Usage
 
Dim instance As TdParameter
Dim value As Object
 
instance.Value = value
 
value = instance.Value
public override object Value {get; set;}
public:
property Object^ Value {
   Object^ get() override;
   void set (    Object^ value) override;
}

Property Value

Specifies an object reference. The default value is null.
Remarks

For input parameters, the Value property is converted into the TdType before data is transmitted to the Advanced SQL Engine.

The Teradata type is inferred from the Value property if TdType is not specified by the application. .NET primitive data types are mapped and converted to Teradata data types; for example System.Int32 data type is mapped to Teradata INTEGER data type by default. For additional information see Converting Data from .NET to Teradata Data Types.

The data provider uses the IConvertible interface for all non-primitive types assigned to the Value property. The data provider first casts the Value property to IConvertible and then invokes a method corresponding to the Teradata data type (for example: IConvertible.ToInt32). The invariant culture (System.Globalization.CultureInfo.InvariantCulture) is used for data type conversions.

To assign a null value (SQL NULL as oppose to null object reference) to a parameter, set the Value property to the System.DBNull.Value property. A null object reference is not the same as System.DBNull. The data provider does not support null object references. Therefore a TdCommand execution results in an exception if one of the associated TdParameter.Value properties is set to a null object reference.

The Value property is overwritten if Direction property is set to InputOutput or Output. TdType, Precision, Scale and Size properties are updated to reflect the returned parameter value.

When a BLOB/CLOB is specified as an Input parameter, the Value property must be set to an object that the provider can use to read the data of the LOB. The provider can read the data of a BLOB using one of the following objects:

Object Type Comments
System.IO.Stream Any object that derives from Stream can be used.
System.Byte[]

When the input parameter is a CLOB, JSON or XML value, the provider can read the data when one of the following type of objects are used:

Object Type Comments
System.IO.TextReader CLOB or JSON only. Any object that derives from TextReader can be used.
System.Xml.XmlReader XML only. Any object that derives from XmlReader can be used.
System.String
System.Char[]

When a LOB has been specified as an output parameter, a TdBlob, TdClob or TdXml will be returned depending upon whether the TdType has been set to TdType.Blob, TdType.Clob/Json or TdType.Xml respectively.

NOTE: If you wish to retreive a LOB output parameter as a String, Stream, Byte[], etc. use the GetValue<T> method instead of using Value.

LOB output parameters maintain their own state, which includes the position within the LOB. The data reader is not able to reset the position to the start of a LOB so you must only call one of the following Properties or Methods, one time:

Example
The following is an example of how to specify that the provider is to read the data of a BLOB using a System.IO.FileStream object: This next example accesses a Clob that has been returned in an InputOutput parameter:
System.IO.FileStream fs = new FileStream("picture.jpg", FileMode.Open, FileAccess.Read);
System.IO.FileInfo fi = new FileInfo("picture.jpg");
command.Parameters.Add(null, TdType.Blob, fi.Length);
command.Parameters[0].Value = fs;
System.IO.StreamReader sr = new StreamReader("textfile.txt");
System.IO.FileInfo fs = new FileInfo("textfile.txt");
             
//Going to setup the parameter 
command.Parameters.Add(null, TdType.Clob, fs.Length);
command.Parameters[0].Direction = ParameterDirection.InputOutput;
command.Parameters[0].Value = sr;
             
//executes a stored procedure that only contains 1 parameter
command.ExecuteNonQuery();
             
//going to access the CLOB that was returned from the stored procedure
TdClob clob1 = (TdClob)command.Parameter[0].Value;
clob1.Read(charBuffer, 0, 25);
                 
//Process buffer...
            
//need to close the CLOB object
clob1.Close();
             
//need to close command when done
command.Dispose();
Requirements

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

See Also

Reference

TdParameter Class
TdParameter Members