Differences

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

Link to this comparison view

Next revision
Previous revision
Last revision Both sides next revision
set_table_by_key [2013/08/06 18:50]
admin created
set_table_by_key [2013/09/12 23:35]
admin [Notes]
Line 3: Line 3:
 ===== Description ===== ===== Description =====
  
-This functor updates or inserts a sub-table corresponding to the given chain of keys in a table.+This functor updates or inserts a sub-table corresponding to the given chain of keys into a table.
  
 ===== Inputs ===== ===== Inputs =====
  
 ^ Name  ^ Type  ^ Description ​ ^ ^ Name  ^ Type  ^ Description ​ ^
-| Table  | [[Table Type|Table]] ​ | The input table.  ​+| Table  | [[Table Type|Table]] ​ | The input table.  ​|
 | Keys  | [[Tuple Type|Tuple]] ​ | Chain of keys identifying the sub-table that will be updated or insert. ​ | | Keys  | [[Tuple Type|Tuple]] ​ | Chain of keys identifying the sub-table that will be updated or insert. ​ |
-| Sub Table  | [[Table Type|Table]] ​ | Sub-table that will be inserted ​in the input table. The column names in the sub-table must match the corresponding names in the input table. The column types must also be compatible. ​  |+| Sub Table  | [[Table Type|Table]] ​ | Sub-table that will be inserted ​into the input table. The column names in the sub-table must match the corresponding names in the input table. The column types must also be compatible. ​  |
  
 ===== Outputs ===== ===== Outputs =====
Line 23: Line 23:
 ===== Notes ===== ===== Notes =====
  
-This functor inserts elements corresponding to the given tuple of keys in the input table. ​For example, given the table below+This functor inserts elements corresponding to the given tuple of keys into the input table. 
 + 
 +**Example 1:** 
 + 
 +Given the table below
  
 ^ Key1*  ^ Key2*  ^ Key3*  ^ Value1 ​ ^ Value2 ​ ^ Value3 ​ ^ ^ Key1*  ^ Key2*  ^ Key3*  ^ Value1 ​ ^ Value2 ​ ^ Value3 ​ ^
Line 36: Line 40:
 |@green: 22  |@green: 12  |@green: "​aaaa" ​ |@green: 23  | |@green: 22  |@green: 12  |@green: "​aaaa" ​ |@green: 23  |
  
-yelds+results in
  
 ^ Key1*  ^ Key2*  ^ Key3*  ^ Value1 ​ ^ Value2 ​ ^ Value3 ​ ^ ^ Key1*  ^ Key2*  ^ Key3*  ^ Value1 ​ ^ Value2 ​ ^ Value3 ​ ^
Line 45: Line 49:
 | 2  | "​d" ​ | 22  | 12  | "​dddd" ​ | 12  | | 2  | "​d" ​ | 22  | 12  | "​dddd" ​ | 12  |
  
-and retrieving ​the sub-table corresponding to the tuple of keys ''<​2>'',​ where 2 corresponds to column "​Key1", ​+**Example 2**: 
 + 
 +Inserting ​the sub-table corresponding to the tuple of keys ''<​2>'',​ where 2 corresponds to column "​Key1", ​
  
 ^ Key2*  ^ Key3*  ^ Value1 ​ ^ Value2 ​ ^ Value3 ​ ^ ^ Key2*  ^ Key3*  ^ Value1 ​ ^ Value2 ​ ^ Value3 ​ ^
Line 52: Line 58:
 |@green: "​d" ​ |@green: 22  |@green: 12  |@green: "​dddd" ​ |@green: 12  | |@green: "​d" ​ |@green: 22  |@green: 12  |@green: "​dddd" ​ |@green: 12  |
  
-yelds+results in
  
 ^ Key1*  ^ Key2*  ^ Key3*  ^ Value1 ​ ^ Value2 ​ ^ Value3 ​ ^ ^ Key1*  ^ Key2*  ^ Key3*  ^ Value1 ​ ^ Value2 ​ ^ Value3 ​ ^
Line 61: Line 67:
 |@lightgreen:​ 2  |@green: "​d" ​ |@green: 22  |@green: 12  |@green: "​dddd" ​ |@green: 12  | |@lightgreen:​ 2  |@green: "​d" ​ |@green: 22  |@green: 12  |@green: "​dddd" ​ |@green: 12  |
  
-If there is already a sub-table corresponding to the sub-table being inserted in the sub-table, the existent sub-table is replaced by the new sub-table. The same is true if the sub-table being inserted is empty. In this case, the existent sub-table is removed from the input table.+If there is already a sub-table corresponding to the sub-table being inserted in the table, the existent sub-table is replaced by the new sub-table. The same is true if the sub-table being inserted is empty. In this case, the existent sub-table is removed from the input table.
  
-It is not possible to insert a sub-table indexed by keys from arbitrary key columns. For example, in the example above, it is not possible to insert 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 Columns]] functor.+It is not possible to insert a sub-table indexed by keys from arbitrary key columns. For example, in the example above, it is not possible to insert 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 =====