Examples
DREREPLACE?DATABASEMATCH=News+Archive HTTP/1.0\n Content-Length:203\n\n #DREDOCID 1\n #DREFIELDNAME Price\n #DREFIELDVALUE 10\n #DREFIELDNAME Color\n #DREFIELDVALUE Red\n #DREDOCREF http://www.example.com/example/dynamic/autopage442.shtml\n #DREFIELDNAME Country\n #DREFIELDVALUE UK\n #DREFIELDNAME Region\n #DREFIELDVALUE South East\n #DREFIELDNAME OnSale\n #DREDELETEFIELDVALUE Yes\n #DRESTATEID abcdefg-6\n #DREFIELDNAME Fruit\n #DREFIELDVALUEIFNOTFOUND mango\n #DREDELETESINGLEFIELDVALUE apple\n #DREDELETEFIELD XML/DOC/DELETEME\n #DREENDDATANOOP\n\n
In this example, the DREREPLACE makes the following changes in the News and Archive databases:
-
In the document with the ID 1:
-
The value of the
Pricefield changes to10. -
The value of the
Colorfield changes toRed.
-
-
In the document with the reference
http://www.example.com/example/dynamic/autopage442.shtml:-
The value of the
Countryfield changes toUK. -
The value of the
Regionfield changes toSouth East. -
The field
OnSaleis removed from the document if it has the valueYes.
-
-
In the documents referenced in the state ID
abcdefg–6:-
The value of the
Fruitfield changes tomangoif theFruit/mangopair does not already exist. -
If the
Fruitfield contains the valueapple, a single instance of theFruit/applepair is deleted. -
All instances of the
XML/DOC/DELETEMEfield are deleted.
-
-
#DREENDDATANOOPsignifies the end of the action parameters.
Edit BitField Values
The following example demonstrates how to use a DREREPLACE action to edit the set information held in BitFieldType fields.
DREREPLACE?ReplaceAllRefs=True HTTP/1.0\n Content-Length:203\n\n #DREALL \n #DREFIELDNAME BitField\n #DREFIELDVALUEIFNOFIELD A008\n #DREFIELDBITOR A008\n #DREDOCID 1274\n #DREFIELDNAME Workbook\n #DREFIELDBITXOR 98\n #DREDBNAME News\n #DREFIELDNAME NewsSets\n #DREFIELDBITAND D9\n #DREENDDATANOOP\n\n
NOTE: The BitField, Workbook, and NewsSets fields used in this example must be BitFieldType fields.
In this example, the DREREPLACE makes the following changes:
-
In all documents in the Content component:
-
If there is no
BitFieldfield, Content adds one with the valueA008. -
Content changes the value in the
BitFieldfield by performing a bitwise OR operation between the current value of the field and the valueA008.For example, if the current value of the field is
8080:Hexadecimal Binary 8080 1000 0000 1000 0000 A008 1010 0000 0000 1000 1010 0000 1000 1000 The new field value is A088The result of the bitwise OR is that any binary digits that were set to
1(indicating that the document was part of the set) are left as they are. In addition, all the documents have the bits set to1for the third, thirteenth, and fifteenth sets, if it was not already set. In this way, all the documents are marked as part of sets 3, 13, and 15.In this example, the document is marked as part of set 3, while remaining a part of sets 7, 11, 13, and 15.
-
-
In the document with ID 1274:
-
Content changes the value in the
Workbookfield by performing a bitwise XOR operation between the current value of the field and the value98. For example, if the current value of the field is6C:Hexadecimal Binary 6C 0110 1100 98 1001 1000 1111 0100 The new field value is F4The result of the bitwise XOR is that any binary digits that are set to
1in either number (but not in both) are set to1in the result. If the document was not already part of sets 3, 4, or 7, Content adds it to those sets. However, if the bit is set to1or0in both numbers, it is set to0in the result. If a document is already part of sets 3, 4, or 7, it is removed from them.In this example, Content adds the document to sets 4 and 7. It remains part of sets 2, 5, and 6, but Content removes it from set 3.
-
-
In all documents in the
Newsdatabase:-
Content changes the value in the
NewsSetsfield by performing a bitwise AND operation between the current value of the field and the valueD9.For example, if the current value of the field is
6C:Hexadecimal Binary 6C 0110 1100 D9 1101 1001 0100 1000 The new field value is 48The result of the bitwise AND is that any binary digits that are set to
1in both numbers are set to1in the result. If a document is already part of set 0, 3, 4, 6, or 7, it remains a part of those sets, but it is not be added if it was not originally part of those sets. It is also removed from any other sets it was initially part of.In this example, the document remains in set 3 and set 6, but Content removes it from sets 2 and 5.
-
-
#DREENDDATANOOPsignifies the end of the action parameters.