POSITION
Given two input expressions, the POSITION function returns an integer value representing the starting position of the first expression within the second expression.
Syntax
POSITION (expression1 IN expression2)
Remarks
|
•
|
This function uses the case-sensitivity setting of the TDV Server (TDV Server > SQL Engine > SQL Language > Case Sensitivity). |
|
•
|
POSITION accepts all string types and all numeric types as input arguments. |
|
•
|
The output is always an integer, provided that none of the input strings is NULL. Otherwise, NULL is returned. |
|
•
|
If either argument is NULL, the function returns NULL. |
|
•
|
If the first argument is a blank string, the function returns 1 (one). |
|
•
|
If the first argument is not found within the second argument, the function returns zero. |
Note: See also the related function INSTR.
Examples
POSITION ('ec' IN 'lecture')
The output returned is 2, because ec starts at the second character position of expression2.
POSITION (' ' IN 'lecture')
The output returned is 0 because expression2 does not contain a space character.
POSITION ('' IN 'lecture')
The output returned is 1 because expression1 is the empty string.