Modes for Merging or Replacing DOM Data

Defines how queried data is handled once passed into FOX.

SYNTAX

<fm:run-query interface=”dbinterface” query=”query” match="XPath" mode=”string”/>

CONCEPTS

The fm:query mode attribute (overridden by fm:run-query) specifies how to process rows:

The PURGE-SELECTED and AUGMENT modes require Row/DOM synchronisation:

To synchronise Row/DOM a result record Primary Key (PK) is required:

Which mode you use is application specific and depends on what DOM data you can afford to lose:

The PURGE-ALL and ADD-TO modes operate faster as no synchronisation processing occurs.

If target-path=”.” (default), only AUGMENT mode is allowed, as Fox will not allow the Subject Element to be removed.

EXAMPLES

<fm:run-query name="qry-add-to" mode="ADD-TO">

<fm:query name="qry-add-to" mode="ADD-TO">
  <fm:target-path match="PRODUCT"/>
  <fm:select>
SELECT *
FROM envmgr.product
WHERE product_nr IN (1001, 1003, 1005)
  </fm:select>
  </fm:query>

<fm:run-query name="qry-augment" mode="AUGMENT">

<fm:query name="qry-augment">
  <fm:target-path match="PRODUCT"/>
  <fm:primary>
    <fm:key>PRODUCT_NR</fm:key>
  </fm:primary>
  <fm:select>
SELECT product_nr, (sale_price - cost_price) Profit
FROM envmgr.product
  </fm:select>
</fm:query>

<fm:query name="qry-purge-all" mode="PURGE-ALL">

<fm:query name="qry-purge-all" mode="PURGE-ALL">
  <fm:target-path match="PRODUCT"/>
  <fm:select>
SELECT product_nr, (sale_price - cost_price) Profit
FROM envmgr.product
  </fm:select>
</fm:query>

<fm:query name="qry-purge-selected" mode="PURGE-SELECTED">

<fm:query name="qry-purge-selected">
  <fm:target-path match="PRODUCT"/>
  <fm:primary>
    <fm:key>PRODUCT_NR</fm:key>
  </fm:primary>
  <fm:select>
SELECT product_nr, (sale_price - cost_price) Profit
FROM envmgr.product
WHERE product_nr IN (1001, 1003, 1005)
  </fm:select>
</fm:query>

EXERCISES

Please use your XX_EMPLOYEEMODULE (where XX are your initials) file for the following exercises.

Exercise 1

Create a query named “qry-userAccount3” that will select the ID, Forename, Surname and Hire_date from scott.employee_search where ID is less than 2,300. Create 4 different buttons named “action-add-to”, “action-augment”, “action-purge-all” and “action-purge-selected” which will run the query with their respective modes. Create a new namespace named “qry-modes” to set-out the actions and create a menu out to display the buttons in the order listed above.

This data should populate the structure /*/EMPLOYEE_LIST/EMPLOYEE in the Theme DOM.

Hint: You may require an extra column (forename || surnameAS full_name) to see exactly the difference between Augment and Purge-Selected.