Previous: , Up: mysql   [Contents][Index]


6.4.2 MySQL Query and SMAP Replies

MySQL query is defined using the following option:

query=template

Define MySQL query template.

The template may reference the following variables:

VariableMeaning
mapName of the map being queried
keyLookup key

Table 6.1: MySQL query template variables

For example:

database alias mysql \
  query="SELECT alias FROM aliases WHERE email='$key'"

If the database definition lacks the query option, it will attempt to use one from the module statement. If the module statement lacked it as well, an error is reported.

Reply templates define the responses to be given. They are given by the following options:

positive-reply=template

Defines a reply to be sent if the query returned a non-empty set of tuples. In addition to the variables described above (see Table 6.1), the template may also refer to the MySQL result columns, by using their names from the ‘SELECT’ part of the query. For example:

database alias mysql \
  query="SELECT alias FROM aliases WHERE email='$key'" \
  positive-reply="OK $alias"

The default positive-reply is ‘OK’.

negative-reply=template

Defines a reply to be sent if the query returned an empty set of tuples. The template may refer to the variables described in Table 6.1.

Default value is ‘NOTFOUND’.

onerror-reply=template

Defines a reply to be sent if an error occurred when executing the query. The template may refer to the variables described in Table 6.1.

Default value is ‘NOTFOUND’.


Previous: , Up: mysql   [Contents][Index]