The Substring Function returns a substring of the contents
of the named column.
SUBSTR(columnname, start, [length])
- columnname
- Name of a character or binary column.
- start
- The position of the first character in the string.
- length
- The number of characters to use.
- If the locale uses a comma as the decimal separator,
you must leave a space after each comma that separates numeric parameters
(for example, after the comma between start and length.
- start and length are
integers greater than or equal to 1.
- start plus length cannot
exceed the total data length plus 1.
- column-name and start value
are required. If you specify only one integer, it is used as the start value.
The substring begins at start and includes the
remainder of the column value.
Example
If the
PHONE_NUMBER column is defined as CHAR(10), you can use the Substring
Function to map the area code. To obtain a substring of the first
three positions of the phone number (area code) for the destination
column, specify:
SUBSTR(PHONE_NUMBER,
1, 3)