SQL/MP Reference Manual

HP NonStop SQL/MP Reference Manual523352-013
S-84
SUBSTRING Function
Each time an outer query selects and evaluates a row, the outer reference is
visible as a new value to the correlated subquery. The correlated subquery
operates on the new value to test its own search condition, so the correlated
subquery executes whenever the outer query selects a new row, which leads to
reduced performance.
If you refer to a column name that occurs in more than one outer query, you must
qualify the column name with the correlation name of the table or view to which it
belongs. The correlation name is known to other subqueries at the same level or to
inner queries but not to outer queries.
If you use the same correlation name at different levels of nesting, an inner query
uses the name from the nearest outer level. SQL checks the FROM clause of the
subquery first, then its outer query, and so forth, until it determines the applicable
table or view.
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 ( 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 }