Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
get_table_from_key [2013/08/06 18:08]
admin
get_table_from_key [2013/08/09 20:27]
127.0.0.1 external edit
Line 22: Line 22:
 ===== Notes ===== ===== Notes =====
  
-This functor ​retrives ​all elements corresponding to the given tuple of keys in the input table. ​For example, given the table below+This functor ​retrieves ​all elements corresponding to the given tuple of keys in the input table. 
 + 
 +**Example 1:** 
 + 
 +Given the table below
  
 ^ Key1*  ^ Key2*  ^ Key3*  ^ Value1 ​ ^ Value2 ​ ^ Value3 ​ ^ ^ Key1*  ^ Key2*  ^ Key3*  ^ Value1 ​ ^ Value2 ​ ^ Value3 ​ ^
Line 31: Line 35:
 | 2  | "​d" ​ | 22  | 12  | "​dddd" ​ | 12  | | 2  | "​d" ​ | 22  | 12  | "​dddd" ​ | 12  |
  
-retrieving the sub-table corresponding to the tuple of keys ''<​2,​ "​a">''​+retrieving the sub-table corresponding to the tuple of keys ''<​2,​ "​a">''​, where 2 corresponds to column "​Key1"​ and "​a"​ corresponds to column "​Key2",​
  
 ^ Key1*  ^ Key2*  ^ Key3*  ^ Value1 ​ ^ Value2 ​ ^ Value3 ​ ^ ^ Key1*  ^ Key2*  ^ Key3*  ^ Value1 ​ ^ Value2 ​ ^ Value3 ​ ^
Line 40: Line 44:
 | 2  | "​d" ​ | 22  | 12  | "​dddd" ​ | 12  ​ | 2  | "​d" ​ | 22  | 12  | "​dddd" ​ | 12  ​
  
-yelds+results in
  
 ^ Key3*  ^ Value1 ​ ^ Value2 ​ ^ Value3 ​ ^ ^ Key3*  ^ Value1 ​ ^ Value2 ​ ^ Value3 ​ ^
Line 46: Line 50:
 |@green: 22  |@green: 12  |@green: "​aaaa" ​ |@green: 23  | |@green: 22  |@green: 12  |@green: "​aaaa" ​ |@green: 23  |
  
-and retriving ​the sub-table corresponding to the tuple of keys ''<​2>''​+**Example 2:** 
 + 
 +Retrieving ​the sub-table corresponding to the tuple of keys ''<​2>''​, where 2 corresponds to column "​Key1", ​
  
 ^ Key1*  ^ Key2*  ^ Key3*  ^ Value1 ​ ^ Value2 ​ ^ Value3 ​ ^ ^ Key1*  ^ Key2*  ^ Key3*  ^ Value1 ​ ^ Value2 ​ ^ Value3 ​ ^
Line 55: Line 61:
 |@lightgreen:​ 2  |@green: "​d" ​ |@green: 22  |@green: 12  |@green: "​dddd" ​ |@green: 12  | |@lightgreen:​ 2  |@green: "​d" ​ |@green: 22  |@green: 12  |@green: "​dddd" ​ |@green: 12  |
  
-yelds+results in
  
 ^ Key2*  ^ Key3*  ^ Value1 ​ ^ Value2 ​ ^ Value3 ​ ^ ^ Key2*  ^ Key3*  ^ Value1 ​ ^ Value2 ​ ^ Value3 ​ ^
Line 63: Line 69:
  
 If the resulting sub-table does not have at least one column of keys or if the given tuple of keys is not present in the input table, an error is reported. If the resulting sub-table does not have at least one column of keys or if the given tuple of keys is not present in the input table, an error is reported.
 +
 +It is not possible to retrieve a sub-table indexed by keys from arbitrary key columns. For example, in the example above, it is not possible to retrieve a sub-table corresponding to keys ''<​2,​ 22>'',​ where 2 corresponds to the first column ("​Key1"​) and 22 corresponds to the third column ("​Key3"​). To do this, first reorder the key columns using the [[Reorder Table Column]] functor.
  
 ===== Internal Name ===== ===== Internal Name =====