Running Queries for Multiple Relations using LET

The following examples show how to use LET statements in XMIM for loading multiple relations. You may use a file or write out the relation names. Save the query and run the Formula Loader using the steps outlined above.

Creating the LET Query

In order to load multiple relations, create a LET query in XMIM. The first example shows how to use a file LET statement.

At the top of the query there are special comments “#” that get parsed.

Example 1:

Using the file: /home/lim/symbols.txt. The symbols.txt file contains the following symbols: NG, CL, HO. The symbols in the file may be separated by white space, commas or by a new line.

#formula_value index=1, relation=USER.${Xsec}, column=Close
LET
Xsec=File “/home/lim/symbols.txt”
SHOW
  1: Close of Xsec
WHEN
Date is after 01/01/2004

In the example above, the following definitions apply:

#formula_value index=1, relation=User.${Xsec}, column=Close

where:

  • #formula_value – tells the program to use this line as a formula definition.

  • index=1 – assigns this formula definition to the corresponding SHOW line. Looks like the label but it is really the nth show attribute.

  • relation=User.${Xsec} – assigns the formula relation name

  • column=Close – assigns a column name.

    An existing MIM column name must be used. See the column names available in the “Column Catalog” located at: http://customers.lim.com/menu/column_catalog.htm for a complete list.

When the formula loader runs the query file, the SHOW statement runs for each symbol in the symbol.txt file (i.e., NG, CL and HO). Notice that the relation name in the #formula_value line at the top of the query file. The ${Xsec} is an identifier telling the formula loader application to rename the relation to the value of the Xsec variable. Therefore, the Close of NG will load as USER.NG and Close of CL will load as USER.CL and so on for each relation listed in the symbols.txt file.

An alternative to using a file in the LET statement is to use a list of relations. For example:

Example 2:

#formula_value index=1, relation=USER.${Xsec}, column=Close
LET
Xsec=NG, CL, HO
SHOW
  1: Close of Xsec
WHEN
Date is after 01/01/2004

This last example shows how to use two relation names in the #formula_value line at the top of the query.

Example 3:

#formula_value index=1, relation=USER.${Xsec}.${Ysec}, column=Close
LET
Xsec=FILE “/home/lim/symbols1.txt”
LET
Ysec=FILE “/home/lim/symbols2.txt”
SHOW
  1: Close of Xsec + Close of Ysec
WHEN
Date is after 01/01/2004

If the file symbols1.txt contains the symbols: NG and HO and the file symbols2.txt contains the symbols: CL and HU then the resulting query will show:

Close of NG + Close of CL
Close of NG + Close of HU
Close of HO + Close of CL
Close of HO + Close of HU