Adding a table reference

To add a table reference:

  1. Add a table in the Referenced Tables grid.
    Note that this table must have an InContext model itself. If it does not have a model, click the Table model icon to create this model.
  2. Add the field mapping to link the referenced table to the current table. These are the possible reference types:
    • Refers: the generated query uses the "refers to" clause to read the referenced data.
    • Where: the generated query uses the "and" clause to read the referenced data. Use this type only if you are sure the referenced data exists; if the referenced data does not exist, no data will be read and the context message may be empty.
    • Nested Query: a nested "select" statement is generated. Use this type to read referenced data if the reference data may not exist.
    • Hook: write your own code in the TableRead hook. Use this type if you cannot read the referenced data with field values you have already available. Example: You need to read data from another table that has the same key as the current table, but in that key also a constant is present, which defines the object type. For example, you have sales orders and warehouse orders, but the warehouse order key contains also the order type.

      The hook must contain a complete SQL statement that retrieves the data of the referenced table. If this referenced table has other references itself, those references are processed automatically based on their reference types.

      Example of a TableRead hook:
      select whinh001.* 
      from	  whinh001
      where	 whinh001.order = :tdsls432.order
      and	   whinh001.type = whtype.sales
      as set with 1 rows
      selectdo
             break
      endselect
      
  3. Refresh the Context Messages.