This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
dev:sql:functions:position [2010/07/08 20:06] els |
dev:sql:functions:position [2010/07/09 03:21] els |
||
---|---|---|---|
Line 3: | Line 3: | ||
====== Omnidex SQL Function: POSITION ====== | ====== Omnidex SQL Function: POSITION ====== | ||
===== Description ===== | ===== Description ===== | ||
- | The POSITION function finds the position of a search_string in a target_string. | + | The POSITION function finds the position of a search_string in a target_string. If the target_string is of length zero, the result is 1. If the search_string occurs as a substring within the target_string, the character position where the search_string first occurs is returned. If neither of these conditions is true, the result is 0. |
- | If the target_string is of length zero, the result is 1. | + | String comparisons are case-sensitive. Use the UPPER and LOWER functions around the search_string and the target_string to produce a case-insensitive search. |
- | If the search_string occurs as a substring within the target_string, the character position where the search_string first occurs is returned. If neither of these conditions is true, the result is 0. | + | This function returns an INTEGER datatype. |
- | + | ||
- | The return data type is a 4-byte INTEGER. | + | |
- | + | ||
- | String comparisons are case-sensitive. Use the UPPER and LOWER functions around the search_string and the target_string to produce a case-insensitive search. | + | |
===== Syntax ===== | ===== Syntax ===== | ||
Line 28: | Line 24: | ||
==== Example 1: Column ==== | ==== Example 1: Column ==== | ||
- | <code SQL> | + | <code> |
> select name, position('.' in name) pos from individuals; | > select name, position('.' in name) pos from individuals; | ||
Line 47: | Line 43: | ||
The following example removes the salutation from the name. | The following example removes the salutation from the name. | ||
- | <code SQL> | + | <code> |
> select trim( | > select trim( | ||
>> substring(NAME | >> substring(NAME |