SUBSTR, SUBSTRB, SUBSTR4
Returns a string that represents a substring of a source string. The returned substring is of a specified number of characters, beginning from a designated starting point, relative to either the beginning or end of the string.
SQL syntax
{SUBSTR | SUBSTRB | SUBSTR4}=(Source, m, n)Parameters
SUBSTR has the parameters:
| Parameter | Description |
|---|---|
|
|
The string for which this function returns a substring. Value can be any supported character data types including If |
|
|
The position at which to begin the substring. If |
|
|
The number of characters to be included in the substring. If |
Description
SUBSTR calculates lengths using characters as defined by character set. SUBSTRB uses bytes instead of characters. SUBSTR4 uses UCS4 code points.
Examples
In the first five rows of employees, select the first three characters of last_name:
SELECT FIRST 5 SUBSTR(last_name,1,3) FROM employees; < Kin > < Koc > < De > < Hun > < Ern > 5 rows found.
In the first five rows of employees, select the last five characters of last_name:
SELECT FIRST 5 SUBSTR(last_name,-5,5) FROM employees; < <NULL> > < chhar > < Haan > < unold > < Ernst > 5 rows found.