Db2 XQuery functions by category
The following categories of Db2 XQuery functions are available: string, boolean, number, date and time, sequence, QName, node, and other.
String functions
| Function | Description |
|---|---|
| codepoints-to-string function | The fn:codepoints-to-string function returns the string equivalent of a sequence of Unicode code points. |
| compare function | The fn:compare function compares two strings. |
| concat function | The fn:concat function returns a string that is the concatenation of two or more atomic values. |
| contains function | The fn:contains function determines whether a string contains a specific substring. The search string is matched using the default collation. |
| ends-with function | The fn:ends-with function determines whether a string ends with a specific substring. The search string is matched using the default collation. |
| lower-case function | The fn:lower-case function converts a string to lowercase. |
| matches function | The fn:matches function determines whether a string matches a specific pattern. |
| normalize-space function | The fn:normalize-space function strips leading and trailing white space characters from a string and replaces each internal sequence of white space characters with a single blank character. |
| normalize-unicode function | The fn:normalize-unicode function performs Unicode normalization on a string. |
| replace function | The fn:replace function compares each set of characters within a string to a specific pattern, and then it replaces the characters that match the pattern with another set of characters. |
| starts-with function | The fn:starts-with function determines whether a string begins with a specific substring. The search string is matched using the default collation. |
| string function | The fn:string function returns the string representation of a value. |
| string-join function | The fn:string-join function returns a string that is generated by concatenating items separated by a separator character. |
| string-length function | The fn:string-length function returns the length of a string. |
| string-to-codepoints function | The fn:string-to-codepoints function returns a sequence of Unicode code points that corresponds to a string value. |
| substring function | The fn:substring function returns a substring of a string. |
| substring-after function | The fn:substring-after function returns a substring that occurs in a string after the end of the first occurrence of a specific search string. The search string is matched using the default collation. |
| substring-before function | The fn:substring-before function returns a substring that occurs in a string before the first occurrence of a specific search string. The search string is matched using the default collation. |
| tokenize function | The fn:tokenize function breaks a string into a sequence of substrings. |
| translate function | The fn:translate function replaces selected characters in a string with replacement characters. |
| upper-case function | The fn:upper-case function converts a string to uppercase. |
Boolean functions
| Function | Description |
|---|---|
| boolean function | The fn:boolean function returns the effective Boolean value of a sequence. |
| false function | The fn:false function returns the xs:boolean value false. |
| not function | The fn:not function returns false if the effective boolean value of a sequence is true and returns true if the effective boolean value of a sequence is false. |
| true function | The fn:true function returns the xs:boolean value true. |
Number functions
| Function | Description |
|---|---|
| abs function | The fn:abs function returns the absolute value of a numeric value. |
| avg function | The fn:avg function returns the average of the values in a sequence. |
| ceiling function | The fn:ceiling function returns the smallest integer that is greater than or equal to a specific numeric value. |
| floor function | The fn:floor function returns the largest integer that is less than or equal to a specific numeric value. |
| max function | The fn:max function returns the maximum of the values in a sequence. |
| min function | The fn:min function returns the minimum of the values in a sequence. |
| number function | The fn:number function converts a value to the xs:double data type. |
| round function | The fn:round function returns the integer that is closest to a specific numeric value. |
| round-half-to-even function | The fn:round-half-to-even function returns the numeric value with a specified precision that is closest to a specific numeric value. |
| sum function | The fn:sum function returns the sum of the values in a sequence. |
Date, time, and duration functions
| Function | Description |
|---|---|
| adjust-date-to-timezone function | The fn:adjust-date-to-timezone function adjusts an xs:date value for a specific time zone or removes the time zone component from the value. |
| adjust-dateTime-to-timezone function | The fn:adjust-dateTime-to-timezone function adjusts an xs:dateTime value for a specific time zone or removes the time zone component from the value. |
| adjust-time-to-timezone function | The fn:adjust-time-to-timezone function adjusts an xs:time value for a specific time zone or removes the time zone component from the value. |
| current-date function | The fn:current-date function returns the current date in the implicit time zone of UTC. |
| current-dateTime function | The fn:current-dateTime function returns the current date and time in the implicit time zone of UTC. |
| current-local-date function | The db2-fn:current-local-date function returns the current date in the local time zone. |
| current-local-dateTime function | The db2-fn:current-local-dateTime function returns the current date and time in the local time zone. |
| current-local-time function | The db2-fn:current-local-time function returns the current time in the local time zone. |
| current-time function | The fn:current-time function returns the current time in the implicit time zone of UTC. |
| dateTime function | The fn:dateTime function constructs an xs:dateTime value from an xs:date value and an xs:time value. |
| day-from-date function | The fn:day-from-date function returns the day component of an xs:date value. |
| day-from-dateTime function | The fn:day-from-dateTime function returns the day component of an xs:dateTime value. |
| days-from-duration function | The fn:days-from-duration function returns the days component of a duration. |
| hours-from-dateTime function | The fn:hours-from-dateTime function returns the hours component of an xs:dateTime value. |
| hours-from-duration function | The fn:hours-from-duration function returns the hours component of a duration value. |
| hours-from-time function | The fn:hours-from-time function returns the hours component of an xs:time value. |
| implicit-timezone function | The fn:implicit-timezone function returns the implicit time zone value of PT0S, which is of type xs:dayTimeDuration. The value PT0S indicates that UTC is the implicit time zone. |
| local-timezone function | The db2-fn:local-timezone function returns the time zone of the local system. |
| minutes-from-dateTime function | The fn:minutes-from-dateTime function returns the minutes component of an xs:dateTime value. |
| minutes-from-duration function | The fn:minutes-from-duration function returns the minutes component of a duration. |
| minutes-from-time function | The fn:minutes-from-time function returns the minutes component of an xs:time value. |
| month-from-date function | The fn:month-from-date function returns the month component of a xs:date value. |
| month-from-dateTime function | The fn:month-from-dateTime function returns the month component of an xs:dateTime value. |
| months-from-duration function | The fn:months-from-duration function returns the months component of a duration value. |
| seconds-from-dateTime function | The fn:seconds-from-dateTime function returns the seconds component of an xs:dateTime value. |
| seconds-from-duration function | The fn:seconds-from-duration function returns the seconds component of a duration. |
| seconds-from-time function | The fn:seconds-from-time function returns the seconds component of an xs:time value. |
| timezone-from-date function | The fn:timezone-from-date function returns the time zone component of an xs:date value. |
| timezone-from-dateTime function | The fn:timezone-from-dateTime function returns the time zone component of an xs:dateTime value. |
| timezone-from-time function | The fn:timezone-from-time function returns the time zone component of an xs:time value. |
| year-from-date function | The fn:year-from-date function returns the year component of an xs:date value. |
| year-from-dateTime function | The fn:year-from-dateTime function returns the year component of an xs:dateTime value. |
| years-from-duration function | The fn:years-from-duration function returns the years component of a duration. |
Sequence functions
| Function | Description |
|---|---|
| count function | The fn:count function returns the number of values in a sequence. |
| data function | The fn:data function returns the input sequence after replacing any nodes in the input sequence by their typed values. |
| deep-equal function | The fn:deep-equal function compares two sequences to determine whether they meet the requirements for deep equality. |
| distinct-values function | The fn:distinct-values function returns the distinct values in a sequence. |
| empty function | The fn:empty function indicates whether an argument is an empty sequence. |
| exactly-one function | The fn:exactly-one function returns its argument if the argument contains exactly one item. |
| exists function | The fn:exists function can check for the existence of many different types of items, such as elements, attributes, text nodes, atomic values (for example, an integer) or XML documents. |
| last function | The fn:last function returns the number of values in the sequence that is being processed. |
| index-of function | The fn:index-of function returns the positions where an item appears in a sequence. |
| insert-before function | The fn:insert-before function inserts a sequence before a specific position in another sequence. |
| one-or-more function | The fn:one-or-more function returns its argument if the argument contains one or more items. |
| position function | The fn:position function returns the position of the context item in the sequence that is being processed. |
| remove function | The fn:remove function removes an item from a sequence. |
| reverse function | The fn:reverse function reverses the order of the items in a sequence. |
| subsequence function | The fn:subsequence function returns a subsequence of a sequence. |
| unordered function | The fn:unordered function returns the items in a sequence in non-deterministic order. |
| zero-or-one function | The fn:zero-or-one function returns its argument if the argument contains one item or is the empty sequence. |
QName functions
| Function | Description |
|---|---|
| in-scope-prefixes function | The fn:in-scope-prefixes function returns a list of prefixes for all in-scope namespaces of an element. |
| local-name-from-QName function | The fn:local-name-from-QName function returns the local part of an xs:QName value. |
| namespace-uri-for-prefix function | The fn:namespace-uri-for-prefix function returns the namespace URI that is associated with a prefix in the in-scope namespaces for an element. |
| namespace-uri-from-QName function | The fn:namespace-uri-from-QName function returns the namespace URI part of an xs:QName value. |
| QName function | The fn:QName function builds an expanded name from a namespace URI and a string that contains a lexical QName with an optional prefix. |
| resolve-QName function | The fn:resolve-QName function converts a string containing a lexical QName into an expanded QName by using the in-scope namespaces of an element to resolve the namespace prefix to a namespace URI. |
Node functions
| Function | Description |
|---|---|
| local-name function | The fn:local-name function returns the local name property of a node. |
| name function | The fn:name function returns the prefix and local name parts of a node name. |
| namespace-uri function | The fn:namespace-uri function returns the namespace URI of the qualified name for a node. |
| node-name function | The fn:node-name function returns the expanded QName of a node. |
| root function | The fn:root function returns the root node of a tree to which a node belongs. |
Other functions
| Function | Description |
|---|---|
| default-collation function | The fn:default-collation function returns a URI that represents the default collation that is defined for the database. |
| sqlquery function | The db2-fn:sqlquery function retrieves a sequence that is the result of an SQL fullselect in the currently connected Db2 database. |
| xmlcolumn function | The db2-fn:xmlcolumn function retrieves a sequence from a column in the currently connected Db2 database. |