12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
- "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
- <sect1 id="IN_Operator">
- <title>IN Operator<indexterm>
- <primary>IN</primary>
- </indexterm><indexterm>
- <primary>IN Operator</primary>
- </indexterm></title>
- <para><emphasis>value </emphasis><emphasis role="bold">IN
- </emphasis><emphasis>value_set</emphasis></para>
- <informaltable colsep="1" frame="all" rowsep="1">
- <tgroup cols="2">
- <colspec align="left" colwidth="122.40pt" />
- <colspec />
- <tbody>
- <row>
- <entry><emphasis>value</emphasis></entry>
- <entry>The value to find in the <emphasis>value_set</emphasis>. This
- is usually a single value, but if the <emphasis>value_set</emphasis>
- is a DICTIONARY with a multiple-component key, this may also be a
- ROW.</entry>
- </row>
- <row>
- <entry><emphasis>value_set</emphasis></entry>
- <entry>A set of values. This may be a set expression, the SET
- function, or a DICTIONARY.</entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- <para>The <emphasis role="bold">IN</emphasis> operator is shorthand for a
- collection of OR conditions. It is an operator that will search a set to
- find an inclusion, resulting in a Boolean return. Using IN is much more
- efficient than the equivalent OR expression.</para>
- <para>Example:</para>
- <programlisting>ABCset := ['A', 'B', 'C'];
- IsABCStatus := Person.Status IN ABCset;
- //This code is directly equivalent to:
- // IsABCStatus := Person.Status = 'A' OR
- // Person.Status = 'B' OR
- // Person.Status = 'C';
-
- IsABC(STRING1 char) := char IN ABCset;
- Trades_ABCstat := Trades(IsABC(rate));
- // Trades_ABCstat is a record set definition of all those
- // trades with a trade status of A, B, or C
- //SET function examples
- r := {STRING1 Letter};
- SomeFile := DATASET([{'A'},{'B'},{'C'},{'D'},{'E'},
- {'F'},{'G'},{'H'},{'I'},{'J'}],r);
- x := SET(SomeFile(Letter > 'C'),Letter);
- y := 'A' IN x; //results in FALSE
- z := 'D' IN x; //results in TRUE
- //DICTIONARY examples:
- rec := {STRING color,UNSIGNED1 code};
- ColorCodes := DATASET([{'Black' ,0 },
- {'Brown' ,1 },
- {'Red' ,2 },
- {'White' ,3 }], rec);
- CodeColorDCT := DICTIONARY(ColorCodes,{Code => Color});
- OUTPUT(6 IN CodeColorDCT); //true
- ColorCodesDCT := DICTIONARY(ColorCodes,{Color,Code});
- OUTPUT(ROW({'Red',2},rec) IN ColorCodesDCT);
- </programlisting>
- <para>See Also: <link linkend="Basic_Attribute_Types">Basic Definition
- Types</link>, <link linkend="Basic_Attribute_Types">Definition Types</link>
- (<link linkend="Set_Attributes">Set Definitions</link>), <link
- linkend="Logical_Operators">Logical Operators</link>, <link
- linkend="PARSE_Pattern_Value_Types">PATTERN</link>, <link
- linkend="DICTIONARY">DICTIONARY</link>, <link linkend="ROW">ROW</link>,
- <link linkend="SET">SET</link>, <link linkend="Recordset_Filtering">Sets and
- Filters</link>, <link linkend="SET_OF">SET OF</link>, <link
- linkend="Set_Operators">Set Operators</link></para>
- </sect1>
|