3.2.51. SUBSTR(string,start[,[length][,padchar]])
Returns the substring of string that starts at start, and has the
length length. Length defaults to the rest of the string. Start
must be a positive whole, while length can be any non-negative
whole number.
It is not an error for start to be larger than the length of
string. If length is specified and the sum of length and start
minus 1 is greater that the length of string, then the result will
be padded with padchars to the specified length. The default value
for padchar is the <space> character.
SUBSTR(‘Foo bar’, 3) –> ‘o bar’
SUBSTR(‘Foo bar’, 3, 3) –> ‘o b’
SUBSTR(‘Foo bar’, 4, 6) –> ‘ bar ‘
SUBSTR(‘Foo bar’, 4, 6, ‘*’) –> ‘ bar**’
SUBSTR(‘Foo bar’, 9, 4, ‘*’) –> ‘****’
PREV NEXT