fm:query, fm:target-path

It is important to know whether your SQL statement will return:
A single result row - between 0 and 1 will only be returned, e.g. from DUAL
Multiple result rows – between 0 and N could be returned, e.g. from ALL_TABLES
Target path must be used when multiple rows are returned from a single run of a query.

SYNTAX

<fm:target-path match=”xpath”/>

CONCEPTS

<fm:target-path match="D/E/F"/> expression:

 

EXAMPLES

  1. Populate /*/TABLE_LIST/TABLE in the Data DOM:
    1. fm:db-interface declaration

<fm:db-interface name="dbint-tab">
  <fm:query name="qry-tab">
  <fm:target-path match="/ROOT/TABLE_LIST/TABLE"/>
   <fm:select>
SELECT *
FROM   tab
   </fm:select>
  </fm:query>
</fm:db-interface>

    1. fm:run-query command

<fm:run-query interface="dbint-tab" query="qry-tab"/>

  1. Populate /*/TABLE_LIST/TABLE in the Theme DOM:
    1. fm:db-interface declaration

<fm:db-interface name="dbint-tab">
   <fm:query name="qry-tab">
   <fm:target-path match="TABLE_LIST/TABLE"/>
    <fm:select>
SELECT *
FROM   tab
    </fm:select>
   </fm:query>
</fm:db-interface>

    1. fm:run-query command

<fm:run-query interface="dbint-tab" query="qry-tab" match=":{theme}"/>

  1. Populate :{theme}/ROLE_LIST using a key:
    1. fm:db-interface declaration

<fm:db-interface name="dbint-web-roles">
   <fm:query name="qry-roles-key">
   <fm:target-path match="./ROLE_LIST/ROLE"/>
    <fm:select>
SELECT
id
, name
, description
FROM   appenv.web_roles
WHERE  app_id = :key
    </fm:select>
   <fm:using name="key">:{user}/WO_ID</fm:using>
   </fm:query>
</fm:db-interface>

    1. fm:run-query command

<fm:run-query interface="dbint-web-roles" query="qry-roles-key" match=":{theme}"/>

EXERCISES

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

Exercise 1

Populate the structure /*/EMPLOYEE_LIST/EMPLOYEE in the Data DOM with the ID, Forename, Surname and Hire_date from scott.employee_search where ID is less than 2,000. Run this query in action-change-date.

Exercise 2

Change the query to populate the Theme DOM instead.