Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Using the Update-statement it is possible to update feature values on items in Perfion. Update works on both selectables and non-selectable features
The below example will set the English value for the selectable feature Color to “Black” for all items that has the feature ItemName set to “1234”.
XML:
Code Block |
---|
<Query> <Update> <Item> <Color language='EN'>Black</Color> </Item> </Update> <From id="Product" /> <Where> <Clause id="ItemName" operator="=" value="1234" /> </Where> </Query> |
JSON:
Code Block |
---|
{ "query": { "Update": { "Item": { "Values": [ { "name": "Color", "language": "EN", "value": "Black" }, ] } }, "From": { "id": "Product" }, "Where": { "Clauses": [ { "Clause": { "id": "ItemName", "operator": "=", "value": "1234" } } ] } } } |
Since Color is a selectable and “Black” hereby represents an item the same can be achieved by the following update:
XML:
Code Block |
---|
<Query> <Update> <Item> <Color id="'347"' /> </Item> </Update> … </Query> |
JSON:
Code Block |
---|
{ "query": { "Update": { "Item": { "Values": [ { "name": "Color", "id": "347" }, ] } }, … } } |
As can be seen it is here the id if the item that is specified instead of the value of it. The result is the same.
The Language-attribute may only be specified for localizable features, and only for selectables if you update them by value rather than by id.
Specifying a value for a selectable only works if the value uniquely defines a single item. If two or more items are named the same, an error will be returned, and nothing will be updated. The same will happen if no item has the specified value.
The base value of an item is updating by using the name value as shown below:
XML:
Code Block |
---|
<Query> <Update> <Item> <Value language='EN'>Some value</Value> </Item> </Update> … </Query> |
JSON:
Code Block |
---|
{ "query": { "Update": { "Item": { "Values": [ { "name": "Value", "language": "EN", "value": "Some value" }, ] } }, … } } |
Updating Parent Item and Brand
Updating Parent Item and Brand is simply adding the attributes “Brand” and/or ParentID to the <Item>-Element.
XML:
Code Block |
---|
<Query> <Update> <Item brand='Virtual' parentID='4455'> <Color language='EN'>Black</Fuel> </Item> </Update> … </Query> |
JSON:
Code Block |
---|
{ "query": { "Update": { "Item": { "brand": "Normal", "parentid": 1234, "Values": [ { "name": "Color", "language": "EN", "value": "Black" }, ] } }, ... } } |
Updating multiple features
Updating multiple features simultaneously is simply achieved by specifying multiple features inside the <Item>-Element.
XML:
Code Block |
---|
<Query> <Update> <Item> <Color language='EN'>Black</Fuel> <EAN>4242003651410</EAN> <Category language='DAN'>Kaffe Maskiner</Category> <PowerW>1800</PowerW> </Item> </Update> … </Query> |
JSON:
Code Block |
---|
{ "query": { "Update": { "Item": { "Values": [ { "name": "Color", "language": "EN", "value": "Black" }, { "name": "EAN", "value": "4242003651410" }, { "name": "Category", "language": "DAN", "value": "Kaffe Maskiner" }, { "name": "PowerW", "value": "1800" }, ] } }, ... } } |
Updating multi-value features
Updating multi-selectable features is achieved by specifying the same feature multiple times. The example below shows exactly this for a selectable multi value. Note that it is allowed to combine assigning values by their id with assigning the values themselves.
XML:
Code Block |
---|
<Query> <Update> <Item> <Catalog id='876' /> <Catalog id='865' /> <Catalog language='EN'>Coffee Maker, Coffee Brewers</Catalog> </Item> </Update> ... </Query> |
JSON:
Code Block |
---|
{ "query": { "Update": { "Item": { "Values": [ { "name": "Catalog", "id": "876" }, { "name": "Catalog", "id": "865" }, { "name": "Catalog", "language": "EN", "value": "Coffee Maker, Coffee Brewers" } ] } }, ... } } |
Clearing values
Clearing a value is done by setting the feature to nothing instead of specifying a value or Item ID.
XML:
Code Block |
---|
<Query> <Update> <Item> <Color /> </Item> </Update> ... </Query> |
JSON:
Code Block |
---|
{ "query": { "Update": { "Item": { "Values": [ { "name": "Color" } ] } }, ... } } |
Support for time zone
When updating items based you can choose to update items based on some criteria where you use some timestamp-information. In such cases it might be useful to be able to supply information about the time zone. This has been possible since version 4.7 as the following example demonstrates:
XML:
Code Block |
---|
<Query> <Update timezone="Eastern Standard Time"> <Item> <Color>Blue</Color> </Item> </Update> <From id="Product" /> <Where> <Clause id="ModifiedDate" operator=">=" value="2020-01-17 11:00:00" /> <Clause id="ModifiedDate" operator="<=" value="2020-01-17 12:00:00" /> </Where> </Query> |
JSON:
Code Block |
---|
{ "query": { "Update": { "Item": { "Values": [ { "name": "Color", "value": "Blue" }, ] } }, "From": { "id": "Product" }, "Where": { "Clauses": [ { "Clause": { "id": "ModifiedDate", "operator": "BETWEEN", "value": [ "2020-01-17 11:00:00", "2020-01-17 12:00:00" ] } } ] } } } |
In the above example all Products modified between 11:00:00 and 12:00:00 (both included) on January 17th, 2020 Eastern Standard Time will have the feature “Color” set to “Blue”. If no time zone is supplied, the above query will use whatever time zone in which the database is running. Before Perfion 4.7 the database time zone where always used.
Table of Contents |
---|