Name

vector — make a vector

Synopsis

 vector ( elem1 any , elem2 any , ... , elem-n any );

Description

vector returns a new vector (one-dimensional array) constructed from the given arguments.

Parameters

elem1..n

Values of any types (not necessarily of one and the same type).

Return Values

A vector (heterogeneous array) of as many elements as there were arguments containing copies of the arguments.

Examples

Example 24.439. Inspecting a vector with dbg_obj_print

SQL clients can not process vectors directly so the simplest way to look at the content of a vector is to print it no server's console.

dbg_obj_print (vector (1, 2.34, 'A string', atof('3.14')))

Example 24.440. Pretty-print function for vectors

The following function gets a heterogeneous vector of strings, nubers and other vectors and returns a string that is an SQL expression that will return a copy of a given vector.

create procedure DUMP_VEC_IMPL (inout _vec any, inout _ses any)
{
declare _len, _ctr integer;
if (193 <> __tag (_vec))
{
if (isstring (_vec))
http (WS.WS.STR_SQL_APOS (_vec), _ses);
else
http (cast (_vec as varchar), _ses);
return;
}
_len := length (_vec);
_ctr := 0;
http ('\nvector (', _ses);
while (_ctr < _len)
{
if (_ctr > 0)
http (', ', _ses);
DUMP_VEC_IMPL (_vec[_ctr], _ses);
_ctr := _ctr+1;
}
http (')', _ses);
}

create function DUMP_VEC (in _vec any)
{
declare _ses any;
_ses := string_output();
DUMP_VEC_IMPL (_vec, _ses);
return string_output_string (_ses);
}

select DUMP_VEC (vector ('abc', 1, vector (3.1415), vector ()));
callret
VARCHAR
_______________________________________________________________________________

vector ('abc', 1,
vector (3.1415),
vector ())

1 Rows.