|
This section covers various behaviors and key information regarding the available data types.
See also Limitations on LONGVARCHAR and LONGVARBINARY .
Pervasive PSQL now supports multiple LONGVARCHAR and LONGVARBINARY columns per table. The data is stored according to the offset in the variable length portion of the record. The variable length portion of data can vary from the column order of the data depending on how the data is manipulated. Consider the following example.
CREATE TABLE BlobDataTest ()Nbr UINT, // Fixed record (Type 14) Clob1 LONGVARCHAR, // Fixed record (Type 21) Clob2 LONGVARCHAR, // Fixed record (Type 21) Blob1 LONGVARBINARY, // Fixed record (Type 21)
On disk, the physical record would normally look like this:
Now alter column Nbr to a LONGVARCHAR column:
On disk, the physical record now looks like this:
[Fixed Data (Nbrheader, Clob1header, Clob2header, Blob1header)][ClobData1][ClobData2][BlobData1] [NbrClobData]
As you can see, the variable length portion of the data is not in the column order for the existing data.
For newly inserted records, however, the variable length portion of the data is in the column order for the existing data.
[Fixed Data (Nbrheader, Clob1header, Clob2header, Blob1header)][NbrClobData][ClobData1][ClobData2] [BlobData1]
See also Limitations on LONGVARCHAR and LONGVARBINARY .
The following limitations apply to the LONGVARCHAR and LONGVARBINARY data types:
Pervasive ODBC Engine Interface compares floating point numbers in comparison predicates using an almost equals algorithm. For example, 12.203 = 12.20300000000001, and 12.203 is >= 12.20300000000001. The epsilon value defined as dbl epsilon is (.2204460492503131e-016). This feature works for large numbers, but > and < will not be detected for small numbers; small numbers will be detected as equal.
Note
If you require precision to many decimal places, use the Decimal data type instead of the Real or Float data type.
Here is the comparison routine that Pervasive ODBC Engine Interface uses for the sql_double data type (which maps to the C double type). For the sql_real data type (which maps to the C float type), Pervasive ODBC Engine Interface uses flt_epsilon, which is (.2204460492503131e-016).
SHORT sCnvDblCmp( DOUBLE d1, DOUBLE d2) { if (d1 == d2) return 0; if (d1 > d2) { if (d1 > d2 + DBL_EPSILON) return(1); } else { if (d2 > d1 + DBL_EPSILON) return(-1); } return(0); }
The DATETIME data type represents a date and time value. The data type is stored internally as two 4-byte integers. The first four bytes store the number of days before or after the base date of January 1, 1900. The other four bytes store the time of day represented as the number of milliseconds after midnight.
The DATETIME data type can be indexed. The accuracy of DATETIME is one three-hundredth of a second.
DATETIME is a relational data type only. No corresponding transactional data type (Btrieve type) is available.
The only permissible format for DATETIME is YYYY-MM-DD HH:MM:SS.mmm. (The CONVERT function contains an optional parameter that allows you to truncate the milliseconds portion of DATETIME. See the "Convert" function under Conversion Functions .)
The following table indicates the data components and their valid values for DATETIME.
The following table explains the rounding used for milliseconds.
The following table shows the resultant data type for addition and subtraction operations of DATE, TIME, TIMESTAMP, and DATETIME with other data types. Data types marked with an "X" are incompatible with DATE, TIME, TIMESTAMP, and DATETIME.
The CONVERT and CAST functions can be used with DATE, DATETIME, TIME, and TIMESTAMP as the following tables explain.
Note
The CONVERT function contains an optional parameter that allows you to truncate the milliseconds portion of DATETIME. See the "Convert" function under Conversion Functions .
The UNIQUEIDENTIFIER data type is a 16-byte binary value known as a globally unique identifier (GUID). A GUID is useful when a row must be unique among other rows.
UNIQUEIDENTIFIER requires a file format of 9.5 or greater .
You can initialize a column or local variable of UNIQUEIDENTIFIER the following ways:
'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' in which each x is a hexadecimal digit in the range 0-9 or A-F. For example, '1129619D-772C-AAAB-B221-00FF00FF0099' is a valid UNIQUEIDENTIFIER value. If you provide a quoted string, all 16 bytes are required. The database engine does not pad a partial string to ensure that it is 16 bytes.
You may use only the following comparison operators with UNIQUEIDENTIFIER values:
|
Operator
|
Meaning
|
|---|---|
|
=
|
Equals
|
|
<> or !=
|
Not equal to
|
|
<
|
Less than
|
|
>
|
Greater than
|
|
<=
|
Less than or equal to
|
|
>=
|
Greater than or equal to
|
|
IS NULL
|
the value is NULL
|
|
IS NOT NULL
|
the value is not NULL
|
Note that ordering is not implemented by comparing the bit patterns of the two values.
You may declare variables of the UNIQUEIDENTIFIER data type and set the variable value with the SET statement.
DECLARE :Cust_ID UNIQUEIDENTIFIER DEFAULT NEWID()
DECLARE :ISO_ID uniqueidentifier
SET :ISO_ID = '1129619D-772C-AAAB-B221-00FF00FF0099'
The UNIQUEIDENTIFER can be coverted with the CAST or CONVERT scalar functions to any of the following data types:
For conversion examples, see Conversion Functions .
When Pervasive PSQL is required by an application to represent infinity, it can do so in either a 4-byte (C float type) or 8-byte (C double type) form, and in either a hexadecimal or character representation, as shown in the following table:
|
Chapter contents
Prev topic: Pervasive PSQL Supported Data Types
|