Name
get_keyword — Find a value in keyword vector
Synopsis
get_keyword ( |
keyword any , |
searched_array vector , | |
default any , | |
no_copy integer ) ; |
Description
get_keyword
performs a case
sensitive seek for the occurrence of keyword
from each even position of
searched_array
. If
found,this returns the element following the occurrence of the
keyword. If the keyword is not found this returns the default
argument or NULL if the default is not supplied.
Parameters
keyword
String key value to be searched in the searched_array at even positions.
searched_array
An array of even length to be searched. Each even position is a string to search. Each odd position can be any value that may then be returned.
default
Any data to be returned if keyword is not matched in the searched_array.
no_copy
By default no_copy is false (0). If passed as true (non-zero integer) then the element to return is the original content of the array and the place in the array from which the element came gets set to 0.
This must in some cases be true, for example when the data being retrieved is not copyable, as in the case of a string output. While the default behavior is to return a copy of the element get_keyword will return the element itself and then set the place from which the element was retrieved to 0 if this argument is true.
Errors
Parameter data type checking errors
Table24.37.Errors signalled by
openxml
SQL Code | Error Message | Virtuoso Code |
---|---|---|
22023 | get_keyword expects a vector of even length, not of length <n> | SR057 |
Return Values
get_keyword
returns the matched
data if it is found. Otherwise it returns the default
. When no default
is defined, NULL is
returned.
Examples
Example24.133.Sample calls
get_keyword(2,vector(1,'primero',2,'segundo', 3,'tercero'),NULL) -> segundo get_keyword('tercero',vector('primero',1,'segundo', 2,'tercero',3), 'NOT FOUND!')) -> 3 x := vector ('a', 2); y := get_keyword ('a', x, -1, 1); The first call returns 2 y := get_keyword ('a', x, -1, 1); the second call returns 0 as the data was set to 0 by the previous call.