update

The update function allows information in the database tables to be updated. This function is similar to the Update standard rule, except that it provides more flexibility.

Only the tables and fields available in the Update standard rule are available for the update extended rule. In the command syntax expression can be a string field, string variable, or string literal. It is important to note that the table and field names for the update extended rule are slightly different than those depicted in the standard rule.

Table 1. Support for the update function
If the map/form is of type ... Then the update function is ...
Export Only valid on the input side of the map.
Import Valid on the input or output side of the map.
Break (Interchange, Group, or Transaction Set) Only valid on the input side of the map.
Build (Interchange, Group, or Transaction Set) Only valid on the input side of the map.
Print Not supported.
Screen entry Not supported.

The update function also enables you to update process data with a string, instead of using the messagebox function.

Note: For the Transaction Register, the updates do not go directly to the database; they are kept in memory until the eventual select, and then they are checked against the database and inserted if necessary.

Common use

The update function is often used as an extended rule instead of a standard rule when you only want to run it based on other criteria. For example, if you want to update a value to Process Data if a quantity is over 100:

If #QTY > 100 then
  Update ProcessData set XPathResult = “LARGE ORDER” where XPath = “MSG”;

It is also commonly written as an extended rule, when there are multiple update statements to be performed, since the standard rule only allows one per field.

Syntax

Syntax 1

update tablename set fieldname = expression [fieldname = expression] where 
  key = expression [and key = expression];
Note: If you are updating multiple fields, each field = expression term should be separated by a comma.

Syntax 2

Updating process data with a string

update ProcessData set XPathResult = <some string>
  where Xpath = <location in process data>;

Examples

Syntax 1

update processdata set xpathresult="hello world" where xpath="example";

Example 2

Updating process data with a string

update ProcessData set XPathResult = #Sender 
where XPath = "SenderID"; 

Additional Information

Also see select and update Options for information about database tables and the associated field names that are available when using the select and update extended rules.