Table of Contents
VARIANT Field
[v7.0]
Range of Type
VARIANT field is able to save different values, from bool to BLOB.
Storage
VARIANT field used more complex storage than a normal field. It is able effectively to store as small value, so BLOBs.
Small values (< PageSize, 4Kib on default) are saved into a logical file similar to VarBinary. Bigger values go into additional logical segment file, like in BLOB.
This information is not important for your development.
Flags
- fNullable
This field can be created as Nullable. In this case, a special bitmap is associated with this field.
- fCompressed
VARIANT field can be created compressed like a BLOB field. In this case, VARIANT field will compress big values. These are values that go into segment file, i.e. have original size > kPageSize (4Rb on default). Notice that picture values are not compressed because they already have a compressed picture format.
You can change this option for a Table with records, but it will take some time of course.
API
This field type is represented at the API level by VVariant Class.
SQL
At SQL Level you can create such field using
CREATE TABLE tblKeyValue( fldKey ULLONG, fldValue VARIANT ); INSERT INTO tblKeyValue VALUES( 1, 578 ); INSERT INTO tblKeyValue VALUES( 2, 'http://SomeUrl' );
In v7.0 we have extend LITERALS to allow specify any supported type. This allows for SQL specify the exact type that should be used to store a variant value.
INSERT INTO tblKeyValue VALUES( 1, "short" '578' ); // saves 578 AS 2-bytes short INTEGER.