POSITION Function (SQL)

Introduction

The POSITION function returns the position of the first occurrence of one string in another.

Syntax

primary-function-position ::=
  POSITION '(' character-string1 IN character-string2
  [ USING char-length-units> ] ')'

character-string1 ::=
  value-expression

character-string2 ::=
  value-expression

char-length-units ::=
  CHARACTERS
  | OCTETS

Remarks

The POSITION function returns the 1-based position of character-string1 in character-string2.

If character-string1 is an empty string, the function returns 1 (one). If character-string1 does not occur in character-string2, the function returns 0 (zero).

If either character-string1 is NULL, or character-string2 is NULL, the function returns NULL.

If the USING clause is omitted, CHARACTERS is assumed.

Examples

1. Find all analog tags containing the word 'Pressure':

SELECT FullName,Value
FROM TagDataPointAnalog
WHERE POSITION( 'Pressure' IN Name ) > 0 

Further Information

Value Expressions (SQL)

To learn more about SQL scalar value expressions.

Fernhill SCADA Structured Query Language (SQL)

To learn more about the SQL features in Fernhill SCADA.

Glossary

For the meaning of terms used in Fernhill SCADA.