lookup Function |
The lookup function returns a value specified by a unique key.
If no value is associated with the key lookup will return null.
lookup(look_tbl, key);
look_tbl | The name of the lookup table to search |
key | The search key |
The following code creates a lookup table based on cities using the post (ZIP) code as a key.
This would allow us to find a city for a given post code.
CREATE LOOKUP cityByPostcode ON %city FROM "data\California" INDEX BY %postcode;
Using the lookup function, we can now match a post code to a city:
lookup(cityByPostCode, "92656");
The above example would (knowing that the post code 92656 is in the city of Aliso Viejo) return 'Aliso Viejo'.
To make it easier to use the same lookup function across several files, you can save and then load a lookup that you have previously created.
To save the lookup, use the following statement:
SAVE LOOKUP cityByPostcode AS "Lookups\CityFromPostcode.db";
To load the lookup, use the following statement:
LOAD LOOKUP cityByPostcode FROM "Lookups\CityFromPostcode.db";