<amend>

Update a specified value, or column of values, either by entering a new value or by using an expression. The expression can be applied to the column the value is in or to another column.

Description

<amend> expects an attribute name which identifies the column to update, and an attribute value which contains the value expression. The value expression may either be an alphanumeric value, or an expression involving any columns in the table. In order for the update to be successful, the expression must produce a result of the same data type of the column to update.

To restrict the update to a subset of rows, instead of the entire column, add the where attribute to use a standard Macro Language selection expression.

<amend> may operate on one column at a time like a <willbe> operation. Or, it may be used in scatter=1 mode to potentially edit multiple columns and rows. This is best visualized through the Trillion-Row Spreadsheet (TRS) grid. For more information, see Amend a single value within the grid in the 1010data Insights Platform User's Guide.

Syntax

<amend name="[COLNAME]" value="[EXPRESSION]" where="[EXPRESSION]"/>

Attributes

name
The name of the column to alter. This attribute accepts a string that obeys Macro Language naming conventions and is the valid name of a column in the table.
value
The expression to transform data, intended to be written to the column mentioned in the name attribute.
Note: The resultant type of the expression must match the current type of the column.
where
Selection criteria for the row on which to apply the amend change. Accepts a standard Macro Language selection expression.
scatter

Enables "scatter" mode, where by values at specific row-column coordinates can be changed to new values via expressions.

The Second Form of <amend>

This syntax allows for multiple columns and rows to be updated in a single operation.

The following CDATA format is valid, and the attributes name, value, and where are not used, when scatter="1":

<amend scatter="1"><![CDATA[
[ROW_POSITION],[COLUMN_NAME],[NEW_VALUE]
]]>
</amend>
[ROW_POSITION]
The row number in the table to amend.
[COLUMN_NAME]
The name of the column to amend.
[NEW_VALUE]
The new value to amend into that location.

Example

Updating one column value of one row in the pub.demo.weather.stations table. The value in the Anemometer Height column for Station ID 3103 is increased by 2.

<base table="pub.demo.weather.stations"/>
<amend name="anht" value="anht+2" where="id=3103"/>
amend value in a column

Example: Scatter

This example updates some text values in the column labeled Station Name which has a column name of name. The format of the CDATA[] block is as follows:

<base table="pub.demo.weather.stations"/>
<amend scatter="1"><![CDATA[
1,name,FROGSTUFF
2,name,CRASHVILLE
3,name,BACON
]]>
</amend>
scatter amend with a set of values