| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488 | [role="xpack"][testenv="basic"][[sql-functions-string]]=== String Functionsbeta[]Functions for performing string manipulation.[[sql-functions-string-ascii]]==== `ASCII`.Synopsis:[source, sql]--------------------------------------------------ASCII(string_exp<1>)--------------------------------------------------*Input*:<1> string expression*Output*: integer.Description:Returns the ASCII code value of the leftmost character of `string_exp` as an integer.["source","sql",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{sql-specs}/docs.csv-spec[stringAscii]--------------------------------------------------[[sql-functions-string-bit-length]]==== `BIT_LENGTH`.Synopsis:[source, sql]--------------------------------------------------BIT_LENGTH(string_exp<1>)--------------------------------------------------*Input*:<1> string expression*Output*: integer.Description:Returns the length in bits of the `string_exp` input expression.["source","sql",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{sql-specs}/docs.csv-spec[stringBitLength]--------------------------------------------------[[sql-functions-string-char]]==== `CHAR`.Synopsis:[source, sql]--------------------------------------------------CHAR(code<1>)--------------------------------------------------*Input*:<1> integer expression*Output*: string.Description:Returns the character that has the ASCII code value specified by the numeric input. The value should be between 0 and 255; otherwise, the return value is data source–dependent.["source","sql",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{sql-specs}/docs.csv-spec[stringChar]--------------------------------------------------[[sql-functions-string-char-length]]==== `CHAR_LENGTH`.Synopsis:[source, sql]--------------------------------------------------CHAR_LENGTH(string_exp<1>)--------------------------------------------------*Input*:<1> string expression*Output*: integer.Description:Returns the length in characters of the input, if the string expression is of a character data type; otherwise, returns the length in bytes of the string expression (the smallest integer not less than the number of bits divided by 8).["source","sql",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{sql-specs}/docs.csv-spec[stringCharLength]--------------------------------------------------[[sql-functions-string-concat]]==== `CONCAT`.Synopsis:[source, sql]--------------------------------------------------CONCAT(string_exp1<1>,string_exp2<2>)--------------------------------------------------*Input*:<1> string expression<2> string expression*Output*: string.Description:Returns a character string that is the result of concatenating `string_exp1` to `string_exp2`. If one of the string is `NULL`, the other string will be returned.["source","sql",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{sql-specs}/docs.csv-spec[stringConcat]--------------------------------------------------[[sql-functions-string-insert]]==== `INSERT`.Synopsis:[source, sql]--------------------------------------------------INSERT(source<1>, start<2>, length<3>, replacement<4>)--------------------------------------------------*Input*:<1> string expression<2> integer expression<3> integer expression<4> string expression*Output*: string.Description:Returns a string where `length` characters have been deleted from `source`, beginning at `start`, and where `replacement` has been inserted into `source`, beginning at `start`.["source","sql",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{sql-specs}/docs.csv-spec[stringInsert]--------------------------------------------------[[sql-functions-string-lcase]]==== `LCASE`.Synopsis:[source, sql]--------------------------------------------------LCASE(string_exp<1>)--------------------------------------------------*Input*:<1> string expression*Output*: string.Description:Returns a string equal to that in `string_exp`, with all uppercase characters converted to lowercase.["source","sql",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{sql-specs}/docs.csv-spec[stringLCase]--------------------------------------------------[[sql-functions-string-left]]==== `LEFT`.Synopsis:[source, sql]--------------------------------------------------LEFT(string_exp<1>, count<2>)--------------------------------------------------*Input*:<1> string expression<2> integer expression*Output*: string.Description:Returns the leftmost count characters of `string_exp`.["source","sql",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{sql-specs}/docs.csv-spec[stringLeft]--------------------------------------------------[[sql-functions-string-length]]==== `LENGTH`.Synopsis:[source, sql]--------------------------------------------------LENGTH(string_exp<1>)--------------------------------------------------*Input*:<1> string expression*Output*: integer.Description:Returns the number of characters in `string_exp`, excluding trailing blanks.["source","sql",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{sql-specs}/docs.csv-spec[stringLength]--------------------------------------------------[[sql-functions-string-locate]]==== `LOCATE`.Synopsis:[source, sql]--------------------------------------------------LOCATE(pattern<1>, source<2>[, start]<3>)--------------------------------------------------*Input*:<1> string expression<2> string expression<3> integer expression; optional*Output*: integer.Description:Returns the starting position of the first occurrence of `pattern` within `source`. The search for the first occurrence of `pattern` begins with the first character position in `source` unless the optional argument, `start`, is specified. If `start` is specified, the search begins with the character position indicated by the value of `start`. The first character position in `source` is indicated by the value 1. If `pattern` is not found within `source`, the value 0 is returned.["source","sql",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{sql-specs}/docs.csv-spec[stringLocateWoStart]--------------------------------------------------["source","sql",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{sql-specs}/docs.csv-spec[stringLocateWithStart]--------------------------------------------------[[sql-functions-string-ltrim]]==== `LTRIM`.Synopsis:[source, sql]--------------------------------------------------LTRIM(string_exp<1>)--------------------------------------------------*Input*:<1> string expression*Output*: string.Description:Returns the characters of `string_exp`, with leading blanks removed.["source","sql",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{sql-specs}/docs.csv-spec[stringLTrim]--------------------------------------------------[[sql-functions-string-octet-length]]==== `OCTET_LENGTH`.Synopsis:[source, sql]--------------------------------------------------OCTET_LENGTH(string_exp<1>)--------------------------------------------------*Input*:<1> string expression*Output*: integer.Description:Returns the length in bytes of the `string_exp` input expression.["source","sql",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{sql-specs}/docs.csv-spec[stringOctetLength]--------------------------------------------------[[sql-functions-string-position]]==== `POSITION`.Synopsis:[source, sql]--------------------------------------------------POSITION(string_exp1<1>, string_exp2<2>)--------------------------------------------------*Input*:<1> string expression<2> string expression*Output*: integer.Description:Returns the position of the `string_exp1` in `string_exp2`. The result is an exact numeric.["source","sql",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{sql-specs}/docs.csv-spec[stringPosition]--------------------------------------------------[[sql-functions-string-repeat]]==== `REPEAT`.Synopsis:[source, sql]--------------------------------------------------REPEAT(string_exp<1>, count<2>)--------------------------------------------------*Input*:<1> string expression<2> integer expression*Output*: string.Description:Returns a character string composed of `string_exp` repeated `count` times.["source","sql",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{sql-specs}/docs.csv-spec[stringRepeat]--------------------------------------------------[[sql-functions-string-replace]]==== `REPLACE`.Synopsis:[source, sql]--------------------------------------------------REPLACE(source<1>, pattern<2>, replacement<3>)--------------------------------------------------*Input*:<1> string expression<2> string expression<3> string expression*Output*: string.Description:Search `source` for occurrences of `pattern`, and replace with `replacement`.["source","sql",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{sql-specs}/docs.csv-spec[stringReplace]--------------------------------------------------[[sql-functions-string-right]]==== `RIGHT`.Synopsis:[source, sql]--------------------------------------------------RIGHT(string_exp<1>, count<2>)--------------------------------------------------*Input*:<1> string expression<2> integer expression*Output*: string.Description:Returns the rightmost count characters of `string_exp`.["source","sql",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{sql-specs}/docs.csv-spec[stringRight]--------------------------------------------------[[sql-functions-string-rtrim]]==== `RTRIM`.Synopsis:[source, sql]--------------------------------------------------RTRIM(string_exp<1>)--------------------------------------------------*Input*:<1> string expression*Output*: string.Description:Returns the characters of `string_exp` with trailing blanks removed.["source","sql",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{sql-specs}/docs.csv-spec[stringRTrim]--------------------------------------------------[[sql-functions-string-space]]==== `SPACE`.Synopsis:[source, sql]--------------------------------------------------SPACE(count<1>)--------------------------------------------------*Input*:<1> integer expression*Output*: string.Description:Returns a character string consisting of `count` spaces.["source","sql",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{sql-specs}/docs.csv-spec[stringSpace]--------------------------------------------------[[sql-functions-string-substring]]==== `SUBSTRING`.Synopsis:[source, sql]--------------------------------------------------SUBSTRING(source<1>, start<2>, length<3>)--------------------------------------------------*Input*:<1> string expression<2> integer expression<3> integer expression*Output*: string.Description:Returns a character string that is derived from `source`, beginning at the character position specified by `start` for `length` characters.["source","sql",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{sql-specs}/docs.csv-spec[stringSubString]--------------------------------------------------[[sql-functions-string-ucase]]==== `UCASE`.Synopsis:[source, sql]--------------------------------------------------UCASE(string_exp<1>)--------------------------------------------------*Input*:<1> string expression*Output*: string.Description:Returns a string equal to that of the input, with all lowercase characters converted to uppercase.["source","sql",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{sql-specs}/docs.csv-spec[stringUCase]--------------------------------------------------
 |