1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
-
- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
- project.
-
- Copyright (C) 1998-2018 OpenLink Software
-
- This project is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; only version 2 of the License, dated June 1991.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-
-->
<refentry id="fn_get_keyword">
<refmeta>
<refentrytitle>get_keyword</refentrytitle>
<refmiscinfo>array</refmiscinfo>
<refmiscinfo>ws</refmiscinfo>
</refmeta>
<refnamediv>
<refname>get_keyword</refname>
<refpurpose>Find a value in keyword vector</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis id="fsyn_get_keyword">
<funcprototype id="fproto_get_keyword">
<funcdef><function>get_keyword</function></funcdef>
<paramdef><parameter>keyword</parameter> any</paramdef>
<paramdef><parameter>searched_array</parameter> vector</paramdef>
<paramdef><optional><parameter>default</parameter> any</optional></paramdef>
<paramdef><optional><parameter>no_copy</parameter> integer</optional></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1 id="desc_get_keyword"><title>Description</title>
<para><function>get_keyword</function> performs a case sensitive seek
for the occurrence of
<parameter>keyword</parameter> from each even position of
<parameter>searched_array</parameter>. 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.</para>
</refsect1>
<refsect1 id="params_get_keyword"><title>Parameters</title>
<refsect2>
<title>keyword</title>
<para>String key value to be searched in the searched_array at
even positions.</para>
</refsect2>
<refsect2>
<title>searched_array</title>
<para>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.</para>
</refsect2>
<refsect2>
<title>default</title>
<para>Any data to be returned if keyword is not matched in
the searched_array.</para>
</refsect2>
<refsect2>
<title>no_copy</title>
<para>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.</para>
<para>
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.
</para>
</refsect2>
</refsect1>
<refsect1 id="errors_get_keyword"><title>Errors</title>
<para><link linkend="datatypeerror">Parameter data type checking errors</link></para>
<table><title>Errors signalled by <function>openxml</function></title>
<tgroup cols="3">
<thead><row><entry>SQL Code</entry><entry>Error Message</entry>
<entry>Virtuoso Code</entry></row></thead>
<tbody>
<row>
<entry><errorcode>22023</errorcode></entry>
<entry>get_keyword expects a vector of even length,
not of length <n></entry>
<entry>SR057</entry>
</row>
</tbody>
</tgroup>
</table>
</refsect1>
<refsect1 id="ret_get_keyword"><title>Return Values</title>
<para><function>get_keyword</function> returns the matched data if it
is found. Otherwise it returns the <parameter>default</parameter>.
When no <parameter>default</parameter> is defined, NULL is returned.</para>
</refsect1>
<refsect1 id="examples_get_keyword"><title>Examples</title>
<example id="ex_get_keyword">
<title>Sample calls</title>
<programlisting>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.
</programlisting>
</example>
</refsect1>
<refsect1 id="seealso_get_keyword"><title>See Also</title>
<para><link linkend="fn_get_keyword_ucase">get_keyword_ucase</link></para>
</refsect1>
</refentry>
|