Data Types
Show this topic in Library frames
Table 2-2 lists the data types supported by the Pervasive.SQL data provider and how they are mapped to the .NET Framework types. You can use the table to infer the data types that will be used when a DataSet is filled using a DataAdapter.
This table also identifies the proper accessors for accessing the data when a DataReader object is used directly.
- The Pervasive Data Type column refers to the native type name.
- The PsqlDbType column refers to the Pervasive.SQL data provider's type enumeration. Generally, there is a one to one mapping between the native type and the PsqlDbType. The Pervasive NUMBER data type, which can be either a decimal or a double, is an exception to this rule.
- The .NET Framework Type column refers to the base data types available in the Framework.
- The .NET Framework Typed Accessor column refers to the method that must be used to access a column of this type when using a DataReader.
Table 2-2 Mapping of Pervasive Data Types
|
Pervasive Data Type
|
PsqlDbType
|
.NET Framework Type
|
.NET Framework Typed Accessor
|
|
BFLOAT4
|
BFloat4
|
Single
|
GetSingle()
|
|
BFLOAT8
|
BFloat8
|
Double
|
GetDouble()
|
|
BIGINT
|
BigInt
|
Int64
|
GetDecimal()
|
|
BINARY
|
Binary
|
Byte[]
|
GetBytes( )
|
|
BIT
|
Bit
|
Byte[]
|
GetBytes( )
|
|
CHAR
|
Char
|
String
Char[]
|
GetString( )
GetChars( )
|
|
CURRENCY
|
Currency
|
Decimal
|
GetDecimal( )
|
|
DATE
|
Date
|
DateTime
|
GetDateTime()
|
|
DECIMAL
|
Decimal
|
Decimal
|
GetDecimal()
|
|
DOUBLE
|
Double
|
Double
|
GetDouble()
|
|
IDENTITY
|
Identity
|
Int32
|
GetInt32()
|
|
INTEGER
|
Integer
|
Int32
|
GetInt32( )
|
|
LONGVARBINARY
|
LongVarBinary
|
Byte[]
|
GetBytes( )
|
|
LONGVARCHAR
|
LongVarChar
|
Byte[]
|
GetBytes( )
|
|
NUMERIC
|
Decimal
|
Decimal
|
GetDecimal( )
|
|
NUMERICSA
|
DecimalSA
|
Decimal
|
GetDecimal( )
|
|
NUMERICSTS
|
DecimalSTS
|
Decimal
|
GetDecimal( )
|
|
REAL
|
Real
|
Single
|
GetSingle( )
|
|
SMALLIDENTITY
|
SmallIdentity
|
Int16
|
GetInt16( )
|
|
SMALLINT
|
SmallInt
|
Int16
|
GetInt16( )
|
|
TIME
|
Time
|
Timespan
|
GetValue()
|
|
TIMESTAMP
|
Timestamp
|
DateTime
|
GetDateTime()
|
|
TINYINT
|
TinyInt
|
SByte
|
GetByte( )
|
|
UBIGINT
|
UBigInt
|
UInt64
|
GetUInt64()
|
|
UINTEGER
|
UInteger
|
UInt32
|
GetUInt32( )
|
|
USMALLINT
|
USmallInt
|
UInt16
|
GetUInt16( )
|
|
UTINYINT
|
UTinyInt
|
Byte
|
GetByte( )
|
|
VARCHAR
|
VarChar
|
String
Char[]
|
GetString( )
GetChars( )
|
Mapping Parameter Data Types
The type of the parameter is specific to each data provider. The Pervasive.SQL data provider must convert the parameter value to a native format before sending it to the server. The best way for an application to describe a parameter is to use the data provider-specific type enumeration.
In generic programming circumstances, the data provider-specific type may not be available. When no provider-specific DB type has been specified, the data type will be inferred from either the System.Data.DbType or from the .NET Framework type of the parameter's value.
The Pervasive.SQL data provider uses the following order when inferring the data type of a parameter:
- The data provider uses the provider-specific data type if it has been specified.
- The data provider infers the data type from the System.Data.DbType if it has been specified, but the provider-specific data type has not been specified.
- The data provider infers the data type from the .NET Framework type if neither the provider-specific data type nor the System.Data.DbType have been specified.
Table 2-3 shows how Pervasive.SQL infers its types if only the System.Data.DbType is specified.
Table 2-3 Mapping System.Data.DbTypes to PsqlDbTypes
|
System.Data.DbType
|
PsqlDbType
|
|
AnsiString
|
VarChar
|
|
AnsiStringFixedLength
|
Char
|
|
Binary
|
Binary
|
|
Boolean
|
Integer
|
|
Byte
|
Integer
|
|
Currency
|
Currency
|
|
Date
|
Date
|
|
DateTime
|
Timestamp
|
|
Decimal
|
Decimal
|
|
Double
|
Double
|
|
Int16
|
SmallInt
|
|
Int32
|
Integer
|
|
Int64
|
BigInt
|
|
Sbyte
|
Integer
|
|
Single
|
BFloat4
|
|
String
|
VarChar
|
|
StringFixedLength
|
Char
|
|
Time
|
Time
|
|
Uint16
|
USmallInt
|
|
Uint32
|
UInteger
|
|
Uint64
|
UBigInt
|
|
VarNumeric
|
Decimal
|
Table 2-4 shows the mapping that the data provider uses to infer a data type if neither the provider-specific data type nor the System.Data.DbType are provided.
Table 2-4 Mapping .NET Framework Types to PsqlDbTypes
|
.NET Framework Type
|
PsqlDbType
|
|
Boolean
|
Integer
|
|
Byte
|
Integer
|
|
Byte[]
|
Binary
|
|
DateTime
|
Timestamp
|
|
Decimal
|
Decimal
|
|
Double
|
Double
|
|
Int16
|
SmallInt
|
|
Int32
|
Integer
|
|
Int64
|
BigInt
|
|
Single
|
BFloat4
|
|
String
|
VarChar
|
|
Uint16
|
USmallInt
|
|
Uint32
|
UInteger
|
|
Uint64
|
UBigInt
|
Data Types Supported With Stream Objects
The Pervasive.SQL data provider supports the use of streams as inputs to long data parameters with the data types listed in Table 2-5.
Table 2-5 Supported Stream Objects
|
Provider Data Type
|
Stream Type Supported
|
|
LONGVARBINARY
|
Stream
|
|
LONGVARCHAR
|
TextReader
|
See Using Streams as Input to Long Data Parameters for a discussion of using streams.