A character string.
The character position that begins the Substring. Numeric
Optional. Default = All. The number of characters to include in the Substring. Numeric
Returns a substring portion of a character string.
SUBSTR() returns a Substring of a Input_String. The Substring begins at the specified Starting_Position and continues for the specified Number_Of_Characters. If you omit the Number_Of_Characters parameter, SUBSTR() returns the right portion of the Input_String beginning at the Starting_Position. NOTE: To determine whether one string is a substring of another, use either the $? (substring) operator or the LIKE()function.
substr(FIRSTNAME, 1, 3) -> "Bev", if FIRSTNAME contains "Beverly" substr(FIRSTNAME, 5, 3) -> "rly"
Assume that you want to search your table for all the zip codes that start with "021." You can do this by defining the following filter expression:
substr(ZIP, 1, 3) = "021"
Index keys are limited to 100 characters. If you want to perform a complex ordering on multiple fields, you sometimes may exceed the key length limit if you simply concatenate fields to create the index expression. For example, the following expression includes four fields that are each 30 characters wide and results in a key that is too long:
COMPANY + DEPARTMENT + LASTNAME + FIRSTNAME
You can still achieve the correct order (in most cases) by using the following index expression:
trim(COMPANY) + substr(DEPARTMENT, 1, 15) + substr(LASTNAME, 1, 15) + substr(FIRSTNAME, 1, 10)
Note : This index expression does not work as expected if, for example, two different DEPARTMENTs within the same COMPANY have the same first 15 characters in their name.