FROM_VECTOR
FROM_VECTOR takes a vector as input and returns a string of type
VARCHAR2 or CLOB as output.
Purpose
FROM_VECTOR optionally takes a RETURNING clause to
specify the data type of the returned value.
If VARCHAR2 is specified without size, the size of the
returned value size is 32767.
In SQL, you can optionally specify the storage format of the input
vector in the FORMAT clause, using the tokens
SPARSE or DENSE. The return storage format
cannot be specified in PL/SQL; rather, the output format is determined by the
storage format of the input vector.
There is no support to convert to CHAR,
NCHAR, and NVARCHAR2.
FROM_VECTOR is synonymous with
VECTOR_SERIALIZE.
Parameters
expr must evaluate to a vector. The function returns NULL if expr is NULL.
Examples
-
SELECT FROM_VECTOR(TO_VECTOR('[1, 2, 3]') );Result:
FROM_VECTOR(TO_VECTOR('[1,2,3]')) –--------------------------------------------------------------- [1.0E+000,2.0E+000,3.0E+000] 1 row selected. -
SELECT FROM_VECTOR(TO_VECTOR('[1.1, 2.2, 3.3]', 3, FLOAT32) );Result:
FROM_VECTOR(TO_VECTOR('[1.1,2.2,3.3]',3,FLOAT32)) ------------------------------------------------------------------ [1.10000002E+000,2.20000005E+000,3.29999995E+000] 1 row selected. -
SELECT FROM_VECTOR( TO_VECTOR('[1.1, 2.2, 3.3]', 3, FLOAT32) RETURNING VARCHAR2(1000));Result:
FROM_VECTOR(TO_VECTOR('[1.1,2.2,3.3]',3,FLOAT32)RETURNINGVARCHAR2(1000)) -------------------------------------------------------------------------------- [1.10000002E+000,2.20000005E+000,3.29999995E+000] 1 row selected. -
SELECT FROM_VECTOR(TO_VECTOR('[1.1, 2.2, 3.3]', 3, FLOAT32) RETURNING CLOB );Result:
FROM_VECTOR(TO_VECTOR('[1.1,2.2,3.3]',3,FLOAT32)RETURNINGCLOB) -------------------------------------------------------------------------------- [1.10000002E+000,2.20000005E+000,3.29999995E+000] 1 row selected.
Note:
-
Applications using Oracle Client 26ai libraries or Thin mode drivers can fetch vector data directly, as shown in the following example:
SELECT dataVec FROM vecTab;
-
For applications using Oracle Client 26ai libraries prior to 26ai connected to Oracle AI Database 26ai, use the
FROM_VECTORto fetch vector data, as shown by the following example:SELECT FROM_VECTOR(dataVec) FROM vecTab;
Parent topic: Vector Serializers
