... |
|SUBSTRING\(x, y)SUBSTRING\(x FROM y)|Get substring from x, from position y to the end of x|y in \{integer}| |SUBSTRING\(x, y, z)SUBSTRING\(x FROM y FOR z)|Get substring from x from position y with length z|y, z in \{integer}| |
|TO\_CHARS\(x, encoding)|Return a clob from the blob with the given encoding. BASE64, HEX, and the builtin Java Charset names are valid values for the encoding. \[b]|x is a blob, encoding is a string, and returns a clob| |TO\_BYTES\(x, encoding)|Return a blob from the clob with the given encoding. BASE64, HEX, and the builtin Java Charset names are valid values for the encoding.|x in a clob, encoding is a string, and returns a blob| |
|TRANSLATE\(x, y, z)|Translate string x by replacing each character in y with the character in z at the same position|x in \{string}| |TRIM\(\[\[LEADING\|TRAILING\|BOTH] \[x] FROM] y)|Trim the leading, trailing, or both ends of a string y of character x. If LEADING/TRAILING/BOTH is not specified, BOTH is used. If no trim character x is specficed then the blank space ' ' is used.|x in \{character}, y in \{string}| |
... |
\[a] Non\-ASCII range characters or integers used in these functions may produce different results or exceptions depending on where the function is evaluated \(Teiid vs. source). Teiid's uses Java default int to char and char to int conversions, which operates over UTF16 values. |
\[b] See the [Charset JavaDoc|http://java.sun.com/j2se/1.5.0/docs/api/java/nio/charset/Charset.html] for more on supported Charset names. For charsets, un-mappable chars will be replaced with the charset default character. binary formats, such as BASE64, will error in their conversion to bytes is a unrecognisable character is encountered. |
h1. Encoding Functions h2. TO_CHARS Return a clob from the blob with the given encoding. {code:SQL}TO_CHARS(x, encoding [, wellformed]){code} BASE64, HEX, and the built-in Java Charset names are valid values for the encoding \[b]. x is a blob, encoding is a string, wellformed is a boolean, and returns a clob. The two argument form defaults to wellformed=true. If wellformed is false, the conversion function will immediately validate the result such that an unmappable character or malformed input will raise an exception. h2. TO_BYTES Return a blob from the clob with the given encoding. {code:SQL}TO_BYTES(x, encoding [, wellformed]){code} BASE64, HEX, and the builtin Java Charset names are valid values for the encoding \[b]. x in a clob, encoding is a string, wellformed is a boolean and returns a blob. The two argument form defaults to wellformed=true. If wellformed is false, the conversion function will immediately validate the result such that an unmappable character or malformed input will raise an exception. If wellformed is true, then unmappable characters will be replaced by the default replacement character for the character set. Binary formats, such as BASE64 and HEX, will be checked for correctness regardless of the wellformed parameter. \[b] See the [Charset JavaDoc|http://java.sun.com/j2se/1.5.0/docs/api/java/nio/charset/Charset.html] for more on supported Charset names. |
String functions generally take strings as inputs and return strings as outputs.
Unless specified, all of the arguments and return types in the following table are strings and all indexes are 1-based. The 0 index is considered to be before the start of the string.
Function | Definition | Datatype Constraint |
---|---|---|
x || y | Concatenation operator | x,y in {string}, return type is string |
ASCII(x) | Provide ASCII value of the left most character in x. The empty string will as input will return null. | return type is integer |
CHR(x) CHAR(x) | Provide the character for ASCII value x [a] | x in {integer} |
CONCAT(x, y) | Concatenates x and y with ANSI semantics. If x and/or y is null, returns null. | x, y in {string} |
CONCAT2(x, y) | Concatenates x and y with non-ANSI null semantics. If x and y is null, returns null. If only x or y is null, returns the other value. | x, y in {string} |
ENDSWITH(x, y) | Checks if y ends with x. If only x or y is null, returns null. | x, y in {string}, returns boolean |
INITCAP(x) | Make first letter of each word in string x capital and all others lowercase | x in {string} |
INSERT(str1, start, length, str2) | Insert string2 into string1 | str1 in {string}, start in {integer}, length in {integer}, str2 in {string} |
LCASE(x) | Lowercase of x | x in {string} |
LEFT(x, y) | Get left y characters of x | x in {string}, y in {integer}, return string |
LENGTH(x) | Length of x | return type is integer |
LOCATE(x, y) | Find position of x in y starting at beginning of y | x in {string}, y in {string}, return integer |
LOCATE(x, y, z) | Find position of x in y starting at z | x in {string}, y in {string}, z in {integer}, return integer |
LPAD(x, y) | Pad input string x with spaces on the left to the length of y | x in {string}, y in {integer}, return string |
LPAD(x, y, z) | Pad input string x on the left to the length of y using character z | x in {string}, y in {string}, z in {character}, return string |
LTRIM(x) | Left trim x of blank chars | x in {string}, return string |
QUERYSTRING(path [, expr [AS name] ...]) | Returns a properly encoded query string appended to the given path. Null valued expressions are omitted, and a null path is treated as ''. Names are optional for column reference expressions.e.g. QUERYSTRING('path', 'value' as "&x", ' & ' as y, null as z) returns 'path?%26x=value&y=%20%26%20' |
path, expr in {string}. name is an identifier |
REPEAT(str1,instances) | Repeat string1 a specified number of times | str1 in {string}, instances in {integer} return string |
REPLACE(x, y, z) | Replace all y in x with z | x,y,z in {string}, return string |
RIGHT(x, y) | Get right y characters of x | x in {string}, y in {integer}, return string |
RPAD(input string x, pad length y) | Pad input string x with spaces on the right to the length of y | x in {string}, y in {integer}, return string |
RPAD(x, y, z) | Pad input string x on the right to the length of y using character z | x in {string}, y in {string}, z in {character}, return string |
RTRIM(x) | Right trim x of blank chars | x is string, return string |
SUBSTRING(x, y)SUBSTRING(x FROM y) | Get substring from x, from position y to the end of x | y in {integer} |
SUBSTRING(x, y, z)SUBSTRING(x FROM y FOR z) | Get substring from x from position y with length z | y, z in {integer} |
TRANSLATE(x, y, z) | Translate string x by replacing each character in y with the character in z at the same position | x in {string} |
TRIM([[LEADING|TRAILING|BOTH] [x] FROM] y) | Trim the leading, trailing, or both ends of a string y of character x. If LEADING/TRAILING/BOTH is not specified, BOTH is used. If no trim character x is specficed then the blank space ' ' is used. | x in {character}, y in {string} |
UCASE(x) | Uppercase of x | x in {string} |
UNESCAPE(x) | Unescaped version of x. Possible escape sequences are \b - backspace, \t - tab, \n - line feed, \f - form feed, \r - carriage return. \uXXXX, where X is a hex value, can be used to specify any unicode character. \XXX, where X is an octal digit, can be used to specify an octal byte value. If any other character appears after an escape character, that character will appear in the output and the escape character will be ignored. | x in {string} |
[a] Non-ASCII range characters or integers used in these functions may produce different results or exceptions depending on where the function is evaluated (Teiid vs. source). Teiid's uses Java default int to char and char to int conversions, which operates over UTF16 values.
Return a clob from the blob with the given encoding.
TO_CHARS(x, encoding [, wellformed])
BASE64, HEX, and the built-in Java Charset names are valid values for the encoding [b]. x is a blob, encoding is a string, wellformed is a boolean, and returns a clob. The two argument form defaults to wellformed=true. If wellformed is false, the conversion function will immediately validate the result such that an unmappable character or malformed input will raise an exception.
Return a blob from the clob with the given encoding.
TO_BYTES(x, encoding [, wellformed])
BASE64, HEX, and the builtin Java Charset names are valid values for the encoding [b]. x in a clob, encoding is a string, wellformed is a boolean and returns a blob. The two argument form defaults to wellformed=true. If wellformed is false, the conversion function will immediately validate the result such that an unmappable character or malformed input will raise an exception. If wellformed is true, then unmappable characters will be replaced by the default replacement character for the character set. Binary formats, such as BASE64 and HEX, will be checked for correctness regardless of the wellformed parameter.
[b] See the Charset JavaDoc for more on supported Charset names.