Question about the <Replace></Replace> Tag

psoglav

Chieftain
Joined
Apr 16, 2016
Messages
4
I was looking through the XML files and saw the <Replace></Replace> tag used in some of the expansion Unit.xml and Building.xml files. What is it used to do?
 
<Row> is used to add a new thing to a table which does not already exist in that table

<Replace> is used to, as the name implies, replace a specific thing in a table which already exists there - that is, completely redefine the whole thing without actually removing it

<Update> is used to change specific attributes of a specific thing in a table. You could use it to change anywhere from 1 to all attributes.

<Delete> is used to remove a thing from a table

<InsertOrAbort> is equivalent to <Row> if the thing doesn't already exist in the table; else, it does nothing
 
It also needs to be defined what the "thing" is. If I understand it correctly, <Replace> should be used only with tables that have a Type column, and replaces the row that has the same Type.
 
Both <Replace> and <InsertOrAbort> require primary keys - so only tables with a Type column.

The differences between <Row>, <Replace> and <InsertOrAbort> are only noticeable if there is already a row in the table with the same value for Type, ie a conflict occurs

Row - causes the transaction to fail, the entire XML file is discarded
Replace - effectively deletes the existing row and adds the new one, the transaction does not fail, the rest of the XML is processed
InsertOrAbort - effectively discards the new one and keeps the old one, the transaction does not fail, the rest of the XML is processed
 
Back
Top Bottom