VECTOR_SERIALIZE scalar function

Converts a VECTOR value into a string representation.

Read syntax diagramSkip visual syntax diagramVECTOR_SERIALIZE(vector-expressionRETURNINGVARCHAR( integerOCTETSCODEUNITS32)CLOB(1M)(integerKMGOCTETSCODEUNITS32))

The schema is SYSIBM.

vector-expression
An expression that returns a VECTOR data type.

Result

If the optional RETURNING clause is omitted, the result string unit is OCTETS and the result type and length depend on the coordinate-type and the dimension attribute of vector-expression:
Coordinate Type Dimension attribute D Result type Result length attribute in OCTETS
FLOAT32 D <= 2041 VARCHAR D x 16 + 1
FLOAT32 D > 2041 CLOB D x 16 + 1
INT8 D <= 6534 VARCHAR D x 5 + 1
INT8 D > 6534 CLOB D x 5 + 1

Usage notes

The VECTOR function is required for converting vector data from a human-readable string format, such as '[0.123, -0.456, 0.789]', into a binary format that can be efficiently stored in a VECTOR-type column.

Examples

The following example shows the command syntax for running a VECTOR_SERIALIZE command:
SELECT VECTOR_SERIALIZE(RVECTOR) as VECTOR FROM VECTOR_TB FETCH FIRST 1 ROWS ONLY
The following example shows the output from the SELECT statement:
VECTOR
-------------------------------------------------
[-0.0762727037,0.0559631996,-0.0107453996]

  1 record(s) selected.