The Schema collections return metadata for the Advanced SQL Engine objects. The notable metadata columns for the Number data type are:
Column Name | Description |
---|---|
COLUMN_TYPE orDATA_TYPE |
Set to NUMBER. |
NUMERIC_PRECISION | Set to 38. |
FORMAT | Format assigned to the SQL Engine object. |
PROVIDERDBTYPE | It is set to TdType.Number. |
COLUMN_INFO | It is either set to FIXED or FLOAT. FIXED indicates that the NUMBER represents a fixed decimal. FLOAT indicates that the NUMBER represents a floating decimal. |
The TdDataReader.GetSchemaTable returns result set metadata. The notable metadata columns for the Number data type are:
If the Number is a floating point decimal this column will be set null (DBNull.Value).
Column Name | Description |
---|---|
NumericPrecision |
If the Number is a fixed point decimal the precision can range from 1 to 38 corresponding to the object (Column, Stored Procedure parameter ...) declaration. For a Number that is a floating point decimal the precision will be 38. This is the maximum number of digits supported in the mantissa. |
NumericScale |
For a Number that is a fixed point decimal the scale can range from 0 to 38 and corresponds to the object (Column, Stored Procedure parameter ...) declaration. It is equal to or less than the NumericPrecision. |
DataType | System.Type object for the System.Double type. |
ProviderType | Set to TdType.Number. |
Format | Format assigned to the SQL Engine object. |
ProviderSpecificDataType |
System.Type object for the TdNumber structure. |
If the TdParameter.TdType property is set to TdType.Number the TdParameter.Precision and TdParameter.Scale properties do not need to be set. This holds whether the column/parameter is defined as a floating or fixed decimal.
The number will be rounded if the TdParameter.TdType property is defined as a TdType.Double. The reason for this is that TdNumber can support a mantissa of up to 38 digits. System.Double can only support a mantissa that is up to 15 digits.
C# |
Copy Code |
---|---|
TdParameter quantity = new TdParameter(); quantity.TdType = TdType.Number; quantity.Value = TdNumber.Parse("435924.9999e-15"); |
The number that is to be inserted will be rounded at the 15 position --.000000000435925.
![]() |
---|
The values for the TdParameter.Precision and TdParameter.Scale are ignored when the TdParameter.TdType property is set to TdType.Number. |
The following example shows how to configure a TdNumber parameter using DbType type declaration and a BCL value.
C# |
Copy Code |
---|---|
TdParameter quantity = new TdParameter();
quantity.DbType = DbType.Double;
quantity.Value = 1000.23e10; |
The following example shows how to configure a Number parameter using TdType type declaration and a Provider Specific value.
C# |
Copy Code |
---|---|
TdParameter quantity = new TdParameter(); quantity.TdType = TdType.Number; quantity.ProviderSpecificValue = TdNumber.Parse("1.23456789076543210239458601992884799e36"); |
The following methods and properties return the column or parameter value as a System.Double structure.
The following Provider Specific Value methods and property return the column or parameter value as a TdNumber structure.
C# |
Copy Code |
---|---|
using (TdConnection cn = new TdConnection("data source=DS1;UserId=Joe;Password=XY;")) { cn.Open(); TdCommand cmd = cn.CreateCommand(); // Price is defined as NUMBER(25, 2) cmd.CommandText = "SELECT Id, Price from Order where Quantity > ?"; cmd.Parameters.Add("quantity", TdType.Decimal); cmd.Parameters["quantity"].Value = 12561M; using (TdDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { Console.WriteLine("[System.Double] Price = {0}", reader.GetDouble(1).ToString()); Console.WriteLine("[TdNumber] Price = {0}", reader.GetTdNumber(1).ToString()); } } } } /* Output: [System.Double] Price = 1.23456789012378e12; [TdNumber] Price = 1.23456789012378e12; */ |
Accessor Methods for Retrieving Data
Configuring Parameters and Parameter Data Types