Previous Next JavaScript must be enabled to correctly display this content

## PUT Clause

Syntax

    put_clause ::= path_expression expression

Semantics

The PUT clause is used primarily to add new fields into one or more maps. It consists of a target expression, which should normally return one or more map item and a new-fields expression that returns one or more maps or records, whose fields are inserted in the target maps.

The PUT clause iterates over the sequence returned by the target expression. For each target item, if the item is not a map it is skipped. Otherwise, the new-fields expression is computed for the current target map. The new-maps expression may reference the $ variable, which is bound to the current target map.

If the new-fields expression returns nothing, the PUT is a no-op. Otherwise, for each item returned by the new-fields expression, if the item is not a map or a record, it is skipped, else, the fields of the map/record are "merged" into the current target map. This merge operation will insert a new field into the target map if the target map does not already have a field with the same key; Otherwise, it will set the value of the target field to the value of the new field.

See Example: Updating Rows.