# 22. Virtuoso Functions Guide - length

Chapter Contents | Prev | Next
Keyword Search:
www.openlinksw.com
docs.openlinksw.com
Book Home
Contents
Preface
Virtuoso Functions Guide
Administration
Aggregate Functions
Array Manipulation
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
ascii
atoi
blob_to_string
blob_to_string_outpu...
chr
initcap
isblob
isstring
lcase
left
length
locate
ltrim
make_string
regexp_instr
regexp_like
regexp_match
regexp_parse
regexp_replace
regexp_substr
repeat
replace
right
rtrim
search_excerpt
serialize
space
split_and_decode
sprintf
strcasestr
strchr
string_output
string_output_flush
string_output_gz_com...
string_output_string
string_to_file
strrchr
strstr
subseq
substring
tmp_file_name
trim
ucase
upper
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

## length

Get length of argument
integer length (in arg any);
Description

Returns the length of its argument.

Argument type | Value returned
--- | ---
string | number of characters
array | number of elements
NULL | zero
LOB | length if known (see below)
string_session | number of bytes written into the session
composite | sum of byte lengths of elements consisting the composite

Note:
In case of a LOB that does not have a length as in the case of one supplied by a client with SQLPutData and not yet stored, a zero is returned.
Parameters
arg – Any type that can be tested for length.
Return Values

Integer length of the argument

Errors

sqlstate | error code | error text
--- | --- | ---
22023 | SR015 | Function length is not applicable to XML tree entity | Length cannot calculate a length for a non-persistent XML entity.
22023 | SR016 | Function length does not handle arguments of type x | An invalid data type was passed as an argument to length

Examples
Some uses of length()

    SQL> select length('abacus'), length (NULL);
    callret   callret
    INTEGER   INTEGER
    _______________________________________________________________________________

    6         0

    1 Rows. -- 11 msec.
    SQL> select max (length (ProductName)) from Demo.demo.Products;
    flag
    INTEGER
    _______________________________________________________________________________

    32

    1 Rows. -- 61 msec.