# 22. Virtuoso Functions Guide - vector

Chapter Contents | Prev | Next
Keyword Search:
www.openlinksw.com
docs.openlinksw.com
Book Home
Contents
Preface
Virtuoso Functions Guide
Administration
Aggregate Functions
Array Manipulation
aref
aset
concat
concatenate
dvector
get_keyword
get_keyword_ucase
isarray
make_array
position
serialize
split_and_decode
tree_md5
vector
vector_concat
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
Remote SQL Data Source
Replication
SOAP
SQL
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web Server & Internet
XML
XPATH & XQUERY
Functions Index

## vector

make a vector
vector ( elem1 any, elem2 any, ... , elem-n any);
Parameters
elem1..n – array, vector or string.
Return Values

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

Description

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

Examples
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')))

Pretty-print function for vectors

The following function gets a heterogenious 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.

See Also

aset aref vector_concat