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.