<query>

Stores a set of MDB query operations and performs the calculations when results are required for use.

Description

<query> may be indexed to return a scalar either as @foo.column.row or @foo.row.column; it may be partially indexed to return a package with @foo.row or a list with @foo.column; @foo._rows returns the number of rows and @foo._cols returns a list of column names; and @foo._column.column returns a package of metadata for the specified column.

Rather than storing a full copy of a table's data in memory, it stores the MDB ops for the query yielding that table. @foo._xml yields the code corresponding to these ops as an XML value.

Syntax

<query name="variable">
     [1010data_QUERY]
</query>

Attributes

name
Defines the name of the query, which can then be referenced elsewhere in the code.

Example

Store a basic set of MDB query operations in a query object, then index into that object to illustrate the calculation and retrieval of values.

<block>
  <query name="queryvalue">
    <base table="pub.demo.retail.item"/>
    <sel value="transid=532"/>
  </query>
  <willbe name="query_test" value="{@queryvalue.transid}"/>
 </block>
Display column of TransID values from result

Example

Show the original MDB query operations stored in this query object

<block>
  <query name="queryvalue">
    <base table="pub.demo.retail.item"/>
    <sel value="transid=532"/>
  </query>
<willbe name="query_test" value="'{@queryvalue._xml}'"/>
</block>
Display original macro code query

Example

Populate a new <table> object with a column from this stored query. The query is not executed until it is necessary to return the values for transid.


<block>
  <query name="queryvalue">
    <base table="pub.demo.retail.item"/>
    <sel value="transid=532"/>
  </query>
  <table />
  <willbe name="foo" value="{@queryvalue.transid}"/> 
</block>
Create table based on a column from this stored query