Position Function; Considerations For Position; Result Of Position; Using The Upshift Function - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

POSITION Function

The POSITION function searches for a given substring in a character string. If the substring is
found, Neoview SQL returns the character position of the substring within the string. The result
returned by the POSITION function is equal to the result returned by the LOCATE function.
POSITION (substring-expression IN source-expression)
substring-expression
is an SQL character value expression that specifies the substring to search for in
source-expression. The substring-expression cannot be NULL. See
Value Expressions" (page
source-expression
is an SQL character value expression that specifies the source string. The
source-expression cannot be NULL. See
Neoview SQL returns the result as a 2-byte signed integer with a scale of zero. If
substring-expression is not found in source-expression, Neoview SQL returns zero.

Considerations for POSITION

Result of POSITION

If the length of source-expression is zero and the length of substring-expression is
greater than zero, Neoview SQL returns 0. If the length of substring-expression is zero,
Neoview SQL returns 1.
If the length of substring-expression is greater than the length of source-expression,
Neoview SQL returns zero. If source-expression is a null value, Neoview SQL returns a null
value.

Using the UPSHIFT Function

To ignore case in the search, use the UPSHIFT function (or the LOWER function) for both the
substring-expression and the source-expression.

Examples of POSITION

This function returns the value 8 for the position of the substring 'John' within the string
:
POSITION ('John' IN 'Robert John Smith')
Suppose that the EMPLOYEE table has an EMPNAME column that contains both the first
and last names. Return all records in table EMPLOYEE that contain the substring 'Smith'
regardless of whether the column value is in uppercase or lowercase characters:
SELECT * FROM persnl.employee
WHERE POSITION ('SMITH' IN UPSHIFT(empname)) > 0 ;
208).
"Character Value Expressions" (page
"Character
208).
POSITION Function
383

Advertisement

Table of Contents
loading

Table of Contents