DBI_QUERY -- make simple requests to a database.
Each query consist of two parts: a query statement (mostly is a
SELECT
statement) and output formatting filters. SQL statement starts just after
the leading
%DBI_QUERY{...}%
declaration. The filters are defined by
.header
,
.body
, and
.footer
keywords each starting at the beginning
of line. Their meaning shall be obvious from their name:
Declaration |
Description |
.header |
It is prepended to the query output once. |
.body |
It is repeated for each row of data being fetched from the database. |
.footer |
It is appended to the query output. |
Parameters
Parameter |
Description |
Default |
Required |
"db_identifier" |
Database ID as defined in the plugin configuration. See DatabaseContrib configuration section. |
none |
required |
subquery="name" |
Defines a subquery which does not produce immediate result but could be used from inside another query -- see %DBI_SUBQUERY% |
none |
optional |
unquoted="col1 col2 ..." |
List of columns to be left unquoted in the output. Read more in Quoting of Values section. |
none |
optional |
protected="col1 col2 ..." |
List of columns to be protected from processing by Foswiki engine. |
none |
optional |
A small note on
protected
parameter. Say, one has an arbitrary data
in a displayed column which could contain any kind of text strings. What
happens if such a string looks like a Foswiki variable or macro? It's gonna be
expaded for sure. Adding a column to the
protected
list makes data from
this column displayed as is, unmodified.
DBI_SUBQUERY -- call a %DBI_XXX% subquery
%DBI_SUBQUERY{"name"}%
(aliased as
%DBI_EXEC%
) doesn't exist as a separate variable but only as a part of
header/body/footer processing mechanism. It's functionality is described in
Variable Expansion
and
Subqueries sections of
DBIQueryPlugin documentation.
Examples
%DBI_QUERY{"db_identifier" ...}%
SELECT ...
.header
head
.body
%column%
%DBI_SUBQUERY{"name"}%
.footer
footer
%DBI_QUERY%