# 22. Virtuoso Functions Guide - aref

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

## aref

returns specific element of an array or string
aref ( arg any, nth integer);
Description

aref returns the nth element of an array, string or string_session, where nth is a zero-based index. If the first argument is a string or string_session, the integer ASCII value of the nth character is returned. If the first argument is an array of any, then the corresponding element is returned.

Parameters
arg – array, vector or string.
nth – integer zero-based index.
Return Values

An integer character code or nth element as whatever type the element is if arg is an array or vector (heterogeneous array.)

Errors

SQLState | Error Code | Error Text | Description
--- | --- | --- | ---
22003 | SR017 | aref: Bad array subscript (zero-based) %d for an arg of type %s (%d) and length %d. |
22023 | SR000 | aref expects an array or vector, not an arg of type %d. |

Examples
Simple examples

    SQL> select aref ('Abacus', 0);
    callret
    VARCHAR
    _______________________________________________________________________________

    65

    1 Rows. -- 3 msec.
    SQL> select aref (vector ('Primero', 2, 3.333), 2);
    callret
    VARCHAR
    _______________________________________________________________________________

    3.333

    1 Rows. -- 4 msec.
    SQL>

See Also

vector aset ascii