An Example of Work with Database

Incoming message Statistics - An Example of Work with Database.

Example Description

This example shows how the Database Access processor, used to exchange data with databases, works. This component allows specification of the data source, SQL instruction template, and names of variables data to be sent to.

To load the example, load the rules list rules.txt from the Examples\Database folder.

The example is the solution of the task of maintaining incoming messages statistics. When a message is received, sender's name and e-mail address are stored in the database. For each sender, the total number of received messages, dates of receiving the first and the last message are also stored.

The STATISTIC table from Microsoft Access database stats.mdb located in the Examples\Database folder is used as data source.

The following SQL instructions are used in the example - SELECT, INSERT .. INTO, UPDATE.

Example Rule Description

Filtering

There is the Subject Filter that filters all messages except debug messages from the example.

Processing

Parsing of the sender's name and address.

Search for sender with that name and address in the database.

If no sender is found, the new entry containing the sender name and address and current date is created, incoming messages number is set to 1.

If the sender is found, the last message date is refreshed, and incoming messages number is increased by 1.

Debug Messages

There is one debug message used to show how the rule works.

© 2017 Mediatwins s.r.o. All rights reserved.