Name
matches_like, one_of_these — programmatic LIKE and in-list test functions
Synopsis
integer matches_like(
|
in str varchar, |
| in pattern varchar, | |
in escape varchar); |
integer one_of_these(
|
in item any, |
| in val_or_vec any, | |
... ); |
Description
matches_like returns 1 if str
matches the SQL LIKE pattern and 0 otherwise. The
optional escape argument is a single character used
to suppress the special meaning of % and
_ in the pattern; when omitted, the default escape
character is \. Returns NULL if either string is NULL.
Unlike the LIKE operator, this function can be invoked
dynamically with a pattern computed at runtime.
one_of_these tests whether
item appears among one or more candidate sets and
returns the 1-based index of the first matching set, or 0 if no match.
Each candidate argument may be either a scalar (compared directly) or a
vector (every element is searched). This is useful for compactly
expressing membership against multiple groups without writing a chained
OR.
Examples
Example 24.204. Simple Examples
SQL> select matches_like ('abc-123', 'abc-%');
SQL> select one_of_these ('blue', vector ('red', 'green'), vector ('blue', 'yellow'));
-- returns 2