Categories:
Conversion Functions

TO_VARIANT

Converts any value to VARIANT value or NULL (if input is NULL).

Syntax

TO_VARIANT( <expr> )

Arguments

expr
An expression of any data type.

Usage Notes

  • The TO_VARIANT function cannot be used directly in an INSERT statement. Instead, use INSERT INTO ... SELECT.... The Examples section shows how to do this.

Examples

Create and fill a table:

CREATE TABLE double_demo (variant1 VARIANT);
INSERT INTO double_demo (variant1)
    SELECT TO_VARIANT(3.14);

Retrieve the original value from the VARIANT column:

SELECT TO_DOUBLE(variant1) FROM double_demo;
+---------------------+
| TO_DOUBLE(VARIANT1) |
|---------------------|
|                3.14 |
+---------------------+