The SET statement assigns a value to a variable.
>>-SET--TargetFieldReference--+-----------+--=--SourceExpression->< +-TYPE------+ +-NAMESPACE-+ +-NAME------+ '-VALUE-----'
SourceExpression is an expression that supplies the value to be assigned. It can be any kind of expression and can return a scalar, row or list value.
If the target is a declared scalar variable, SourceExpression is evaluated and assigned to the variable. If need be, its value is converted to the data type of the variable. If this conversion is not possible, there will be either an error at deploy time or an exception at run time.
Null values are handled in exactly the same way as any other value. That is, if the expression evaluates to null, the value "null" is assigned to the variable.
For scalar variables the TYPE, NAME, NAMESPACE, and VALUE clauses are meaningless and are not allowed.
If the target is a declared row variable, one of the predefined row variables, a field within any kind of row variable, a list of fields within any kind of row variable, or a declared reference variable that points to any of these things, the ultimate target is a field. In these cases, the target field is navigated to (creating the fields if necessary).
If array indices are used in TargetFieldReference, the navigation to the target field can only create fields on the direct path from the root to the target field. For example, the following SET statement requires that at least one instance of Structure already exists in the message:
SET OutputRoot.XMLNS.Message.Structure[2].Field = ...
For further information on working with elements of type list see Working with elements of type list
SET OutputRoot = InputRoot;
SET OutputRoot.XMLNS.Order.Name = UPPER(InputRoot.XMLNS.Order.Name);
This example puts one field in the message into uppercase. The first statement constructs an output message that is a complete copy of the input message. The second statement sets the value of the Order.Name field to a new value, as defined by the expression on the right.
If the Order.Name field does not exist in the original input message, it does not exist in the output message generated by the first statement. The expression on the right of the second statement returns NULL (because the field referenced inside the UPPER function call does not exist). Assigning the NULL value to a field has the effect of deleting it if it already exists, and so the effect is that the second statement has no effect.
SET OutputRoot.XMLNS.Order.Name VALUE = NULL;