Build Code Lookup Samples

The lookup operation for a Build script can be refined in many ways. The basic pattern is:

lookup {
   <input>
   <keys>
   <columns>
   <duplicates>
}

The <input> can be any input type, including cbase-input for cBases, text-input for text files, and dive-input for Dives. The input itself can have operations inside, for example: sort, filter, remove, and lookup. You can even lookup inside a lookup's input. Lookup is itself an operation, so you can also do a remove before or after the lookup.

Here is the extended pattern:

<operations>
lookup {
   <cbase-input or text-input or dive-input> {
     <operations>
   } 
   <keys>
   <columns>
   <duplicates> 
}
<operations>

Here are some example scenarios.

NOTE:

  • Lookups are case sensitive.
  • For lookups, null is a valid key.
  • If <unknown> appears as a key for a row, then <unknown> is used for all lookup columns for that row. Best practice is to not have key columns in the base table that contain the value <unknown>.
  • By default, when a build encounters duplicate lookup keys with identical values, that value is used. Otherwise, a warning is issued due to the ambiguity, and <unknown> is used instead. There is only one warning issued per lookup. Use the resolve-duplicates tag to change this behavior. See General Build Tags.

See also: