Difference between revisions of "Data Table"

From PresenceWiki
Jump to: navigation, search
(Manipulating the Data Table)
(Iteration Strategies)
Line 25: Line 25:
 
=== Iteration Strategies ===
 
=== Iteration Strategies ===
  
Presence uses <i>implicit</i> iteration. This means that if a Task Element's settings contain a reference to one or more column names, the Task Element's functionality will be repeated for each unique value for the column(s) referenced.
+
==== Implicit Iteration ====
 +
 
 +
Presence tends to use <i>implicit</i> iteration. This means that if a Task Element's settings contain a reference to one or more column names, the Task Element's functionality will be repeated for each unique value for the column(s) referenced.
  
 
For example, the [[Send Email]] node allows you to use a Column reference to form the subject (as well as the message body, attachments and recipients). Imagine we have a Data Table which contains a Column named 'EMAIL_SUBJECT' and has five rows of data, each with a distinct value for EMAIL_SUBJECT.
 
For example, the [[Send Email]] node allows you to use a Column reference to form the subject (as well as the message body, attachments and recipients). Imagine we have a Data Table which contains a Column named 'EMAIL_SUBJECT' and has five rows of data, each with a distinct value for EMAIL_SUBJECT.
Line 34: Line 36:
  
 
As a result of this a separate email with a unique subject will be generated for each value of EMAIL_SUBJECT in the Data Table.
 
As a result of this a separate email with a unique subject will be generated for each value of EMAIL_SUBJECT in the Data Table.
 +
 +
==== Explicit Iteration ====
 +
 +
Sometimes it can be useful to explicitly iterate over the Data Table. To achieve this you can use the [[Dataset Splitter]], which breaks the Data Table up based on differences in a column value and calls the next Node in the Task repeatedly for each subset of data.
  
 
=== Storing and Retrieving the Data Table ===
 
=== Storing and Retrieving the Data Table ===

Revision as of 12:45, 22 June 2010

Data Table

The Data Table is an object stored in memory as part of the Presence Context. It consists of a series of rows divided into named columns:

http://www.international-presence.com/wikidocs/images/data_table_view.png

Populating the Data Table

The Data Table is automatically populated and appended by Query Task Elements. For example the SQL Query Node will populate the Data Table with the results of the database query, using the Column names and values that are returned in the record set.

Merging Data Tables

The Merge Results Node will merge one ore more Data Tables with either horizontal, vertical or cross-reference strategy.

Joining New Results

If a Data Table is already present in the Presence Context and a new query is performed, the results will be appended to the existing Data Table. If the results of the current (incoming) Data Table are referenced in the new query, the new results will be joined in a logical fashion. For example:

Query A creates a Data Table with the columns 'A', 'B' and 'C'.

This joins to Query B, which returns a Data Table with the columns 'D' and 'E'.

If Query B contains a reference to Column 'A' (for example in the WHERE clause), the query will be repeated for each possible value of 'A' and the subset will be joined to the correct records.

Iteration Strategies

Implicit Iteration

Presence tends to use implicit iteration. This means that if a Task Element's settings contain a reference to one or more column names, the Task Element's functionality will be repeated for each unique value for the column(s) referenced.

For example, the Send Email node allows you to use a Column reference to form the subject (as well as the message body, attachments and recipients). Imagine we have a Data Table which contains a Column named 'EMAIL_SUBJECT' and has five rows of data, each with a distinct value for EMAIL_SUBJECT.

We would reference this Column by placing the following value in the Email Subject field:

 :var{EMAIL_SUBJECT}

As a result of this a separate email with a unique subject will be generated for each value of EMAIL_SUBJECT in the Data Table.

Explicit Iteration

Sometimes it can be useful to explicitly iterate over the Data Table. To achieve this you can use the Dataset Splitter, which breaks the Data Table up based on differences in a column value and calls the next Node in the Task repeatedly for each subset of data.

Storing and Retrieving the Data Table

Two options are available for storing and retrieving the Data Table:

  • Saving it to file and reloading it
  • Saving it to a Variable and reloading it

To store the Data Table to a file, use the Write Context to XML Node. This will store the Data Table along with any local, task or global variables in existence. You can then read it back again (in the same Task, or in a separate Task) using the Read Context from XML Node.

To temporarily store a Data Table in memory (for later retrieval) use the Store Data Table and Retrieve Data Table Nodes. These store the Data Table in a Presence variable.

Manipulating the Data Table

Presence provides the following Nodes to manipulate the contents of the Data Table: