NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
S-83
SUBSTRING Function
SUBSTRING Function
The SUBSTRING function extracts a substring out of a given string.
character-string
specifies the source string from which to extract the substring.
start-position
specifies the starting position within character-string, in number of
characters, at which to start extracting the substring.start-position must be a
value with an exact numeric data type and a scale of 0; otherwise, SQL returns an
error.
substring-length
specifies the number of characters to extract from character-string.
substring-length must be a value of exact numeric data type with a scale of
zero; otherwise, SQL returns an error. substring-length must be greater than
or equal to zero.
Considerations—SUBSTRING Function
The data types of substring-length and start-position must be
numeric; otherwise, SQL returns an error.
If the sum of start-position and substring-length is greater than the
length of the character string, SQL returns the substring from start-position
to the end of the string.
{ SUBSTRING ( character-string FROM start-position }
{ [ FOR substring-len ] ) }
where character-string is:
{ string-literal }
{ column-name }
{ param-name }
{ host-var-name }
{ UPSHIFT function }
{ character-expression }
start-position and substring-length are:
{ numeric-literal }
{ column-name }
{ param-name }
{ host-var-name }
{ expression }