Updating nested tables
The mechanism for updating nested tables (tables within tables) is very similar to updating a single table. The only difference is that nested tables have an outer row number and an inner row number. Each outer row contains a table of inner row values:
Outer Row |
Inner Row |
Data |
1
|
1 |
opinion 1, comment 1 |
2 |
opinion 1, comment 2 |
|
3 |
opinion 1, comment 3 |
|
2 |
1 |
opinion 2, comment 1 |
3 |
1 |
opinion 3, comment 1 |
2 |
opinion 3, comment 2 |
As you can see from the table above, outer row one contains a table with three values, while outer row two has one value and outer row three, two values. The XML representation of the above table would be:
<table name="ecollectionevents">
<tuple>
<table name="LatComment_nesttab">
<tuple>
<table>
<tuple>
<atom>opinion 1, comment 1</atom>
</tuple>
<tuple>
<atom>opinion 1, comment 2</atom>
</tuple>
<tuple>
<atom>opinion 1, comment 3</atom>
</tuple>
</table>
</tuple>
<tuple>
<table>
<tuple>
<atom>opinion 2, comment 1</atom>
</tuple>
</table>
</tuple>
<tuple>
<table>
<tuple>
<atom>opinion 3, comment 1</atom>
</tuple>
<tuple>
<atom>opinion 3, comment 2</atom>
</tuple>
</table>
</tuple>
</table>
</tuple>
</table>
The nested table LatComment_nesttab starts with the <table name="LatComment_nesttab">
tag. Each outer row is enclosed in a <tuple> tag. The outer rows are coloured green. Within each outer row is a table of inner rows. The inner rows are enclosed in red <tuple> tags. When updating nested tables both the outer and inner row <tuple> tags may have row attributes. Hence it is possible to append / prepend / replace outer and / or inner rows.
The equivalent CSV representation is shown below. The table has been turned on its side for ease of viewing. The column names should appear in the first row rather than the first column:
irn |
5000432 |
LatComment_nesttab(1:1) |
opinion 1, comment 1 |
LatComment_nesttab(1:2) |
opinion 1, comment 2 |
LatComment_nesttab(1:3) |
opinion 1, comment 3 |
LatComment_nesttab(2:1) |
opinion 2, comment 1 |
LatComment_nesttab(3:1) |
opinion 3, comment 1 |
LatComment_nesttab(3:2) |
opinion 3, comment 2 |
The outer and inner rows for nested tables in CSV are recorded after the column name enclosed in brackets separated by a colon. The outer row is shown in green, while the inner row is red. The example above uses the short form for the row attributes. The long form would look like:
LatComment_nesttab(row='1':row='1')
As with XML the outer and / or inner rows may contain update modifiers. The following examples detail some common uses.


<table name="ecollectionevents">
<tuple>
<atom name="irn">5000432</atom>
<table name="LatComment_nesttab">
<tuple>
<table>
<tuple>
<atom>new opinion 1, new comment 1</atom>
</tuple>
</table>
</tuple>
<tuple>
<table>
<tuple>
<atom>new opinion 2, new comment 1</atom>
</tuple>
<tuple>
<atom>new opinion 2, new comment 2</atom>
</tuple>
</table>
</tuple>
</table>
</tuple>
</table>

irn |
LatComment_nesttab(1:1) |
LatComment_nesttab(2:1) |
LatComment_nesttab(2:2) |
---|---|---|---|
|
|
|
|
As the first outer row and first inner row do not contain row attributes the current contents of the LatComments_nesttab column will be cleared:
|
|
Before |
|
|
|
After |
1 |
1 |
opinion 1, comment 1 |
|
1 |
1 |
new opinion 1, new comment 1 |
2 |
opinion 1, comment 2 |
|
2 |
1 |
new opinion 2, new comment 1 |
|
3 |
opinion 1, comment 3 |
|
2 |
new opinion 2, new comment 2 |
||
2 |
1 |
opinion 2, comment 1 |
|
|
|
|
3 |
1 |
opinion 3, comment 1 |
|
|
|
|
2 |
opinion 3, comment 2 |
|
|
|
|


<table name="ecollectionevents">
<tuple>
<atom name="irn">5000432</atom>
<table name="LatComment_nesttab">
<tuple row="+">
<table>
<tuple>
<atom>append opinion 1, comment 1</atom>
</tuple>
<tuple>
<atom>append opinion 1, comment 2</atom>
</tuple>
</table>
</tuple>
</table>
</tuple>
</table>

irn |
LatComment_nesttab(+:1) |
LatComment_nesttab(+:2) |
---|---|---|
|
|
|
The first outer row has a row attribute with a value of +, indicating an outer row is to be appended to the existing data. The inner table contains the values to be added:
|
|
Before |
|
|
|
After |
1 |
1 |
opinion 1, comment 1 |
|
1 |
1 |
opinion 1, comment 1 |
2 |
opinion 1, comment 2 |
|
2 |
opinion 1, comment 2 |
||
3 |
opinion 1, comment 3 |
|
3 |
opinion 1, comment 3 |
||
2 |
1 |
opinion 2, comment 1 |
|
2 |
1 |
opinion 2, comment 1 |
3 |
1 |
opinion 3, comment 1 |
|
3 |
1 |
opinion 3, comment 1 |
2 |
opinion 3, comment 2 |
|
2 |
opinion 3, comment 2 |
||
|
|
|
|
4 |
1 |
append opinion 1, comment 1 |
|
|
|
|
2 |
append opinion 1, comment 2 |


<table name="ecollectionevents">
<tuple>
<atom name="irn">5000432</atom>
<table name="LatComment_nesttab">
<tuple row="2">
<table>
<tuple row="+">
<atom>opinion 2, append comment 1</atom>
</tuple>
<tuple>
<atom>opinion 2, append comment 2</atom>
</tuple>
</table>
</tuple>
</table>
</tuple>
</table>

irn |
LatComment_nesttab(2:+) |
LatComment_nesttab(2:+) |
---|---|---|
|
|
|
The outer row contains a fixed row number while the first inner row contains an update modifier, the append (+) modifier. The combination indicates that values are to be appended to the end of the second outer row:
|
|
Before |
|
|
|
After |
1 |
1 |
opinion 1, comment 1 |
|
1 |
1 |
opinion 1, comment 1 |
2 |
opinion 1, comment 2 |
|
2 |
opinion 1, comment 2 |
||
3 |
opinion 1, comment 3 |
|
3 |
opinion 1, comment 3 |
||
2 |
1 |
opinion 2, comment 1 |
|
2 |
1 |
opinion 2, comment 1 |
3 |
1 |
opinion 3, comment 1 |
|
2 |
opinion 2, append comment 1 |
|
2 |
opinion 3, comment 2 |
|
3 |
opinion 2, append comment 2 |
||
|
|
|
|
3 |
1 |
opinion 3, comment 1 |
|
|
|
|
2 |
opinion 3, comment 2 |


<table name="ecollectionevents">
<tuple>
<atom name="irn">5000432</atom>
<table name="LatComment_nesttab">
<tuple row="2-">
<table>
<tuple>
<atom>prepend opinion 2, comment 1</atom>
</tuple>
<tuple>
<atom>prepend opinion 2, comment 2</atom>
</tuple>
</table>
</tuple>
</table>
</tuple>
</table>

irn |
LatComment_nesttab(2-:1) |
LatComment_nesttab(2-:2) |
---|---|---|
|
|
|
The outer row attribute value of 2-
will prepend an outer row before row two and move the existing second row and subsequent rows down. The inner table contains the values to be set:
|
|
Before |
|
|
|
After |
1 |
1 |
opinion 1, comment 1 |
|
1 |
1 |
opinion 1, comment 1 |
2 |
opinion 1, comment 2 |
|
2 |
opinion 1, comment 2 |
||
3 |
opinion 1, comment 3 |
|
3 |
opinion 1, comment 3 |
||
2 |
1 |
opinion 2, comment 1 |
|
2 |
1 |
prepend opinion 2, comment 1 |
3 |
1 |
opinion 3, comment 1 |
|
2 |
prepend opinion 2, comment 2 |
|
2 |
opinion 3, comment 2 |
|
3 |
1 |
opinion 2, comment 1 |
|
|
|
|
|
4 |
1 |
opinion 3, comment 1 |
|
|
|
|
2 |
opinion 3, comment 2 |


<table name="ecollectionevents">
<tuple>
<atom name="irn">5000432</atom>
<table name="LatComment_nesttab">
<tuple row="2=">
<table>
<tuple>
<atom>replace opinion 2, comment 1</atom>
</tuple>
<tuple row="3">
<atom>replace opinion 2, comment 3</atom>
</tuple>
</table>
</tuple>
</table>
</tuple>
</table>

irn |
LatComment_nesttab(2=:1) |
LatComment_nesttab(2=:3) |
---|---|---|
|
|
|
The 2=
row attribute on the outer row indicates row two is to be replaced. Note the use of the row attribute in the inner table to skip row two (causing a blank value to be created):
|
|
Before |
|
|
|
After |
1 |
1 |
opinion 1, comment 1 |
|
1 |
1 |
opinion 1, comment 1 |
2 |
opinion 1, comment 2 |
|
2 |
opinion 1, comment 2 |
||
3 |
opinion 1, comment 3 |
|
3 |
opinion 1, comment 3 |
||
2 |
1 |
opinion 2, comment 1 |
|
2 |
1 |
replace opinion 2, comment 1 |
3 |
1 |
opinion 3, comment 1 |
|
2 |
|
|
2 |
opinion 3, comment 2 |
|
3 |
replace opinion 2, comment 3 |
||
|
|
|
|
3 |
1 |
opinion 3, comment 1 |
|
|
|
|
2 |
opinion 3, comment 2 |


<table name="ecollectionevents">
<tuple>
<atom name="irn">5000432</atom>
<table name="LatComment_nesttab">
<tuple row="3">
<table>
<tuple row="1=">
<atom>opinion 3, replace comment 1</atom>
</tuple>
<tuple row="+">
<atom>opinion 3, append comment 1</atom>
</tuple>
</table>
</tuple>
</table>
</tuple>
</table>

irn |
LatComment_nesttab(3:1=) |
LatComment_nesttab(3:+) |
---|---|---|
|
|
|
The outer row attribute value indicates row three is to be changed, while the first inner row attribute indicates row one is to be replaced. The second inner row attribute will append a value to the end of the inner table:
|
|
Before |
|
|
|
After |
1 |
1 |
opinion 1, comment 1 |
|
1 |
1 |
opinion 1, comment 1 |
2 |
opinion 1, comment 2 |
|
2 |
opinion 1, comment 2 |
||
3 |
opinion 1, comment 3 |
|
3 |
opinion 1, comment 3 |
||
2 |
1 |
opinion 2, comment 1 |
|
2 |
1 |
opinion 2, comment 1 |
3 |
1 |
opinion 3, comment 1 |
|
3 |
1 |
opinion 3, replace comment 1 |
2 |
opinion 3, comment 2 |
|
2 |
opinion 3, comment 2 |
||
|
|
|
|
3 |
opinion 3, append comment 1 |