8.3 Query Examples
These examples have been wrapped for legibility, but they must be entered as a single line in the LISTSERV configuration. Parameters are shown in red for emphasis only.
- Query matching Active Directory users in a particular organizational unit at EXAMPLE.COM:
- Query matching members of a Windows Security Group at EXAMPLE.COM:
- Advanced example: query matching recipients from a DBMS table whose e-mail address is at a particular hostname.
TYPE=DBMS SERVER=nickname SEARCH='SELECT CUST_EMAIL,
CUST_NAME FROM SOMETABLE WHERE CUST_EMAIL LIKE CONCAT(''%%@'',%1)' E-MAIL=CUST_EMAIL
Because LISTSERV inserts all parameters as escaped string constants, it is not possible to form the pattern ‘%@[parameter #1]’ by entering ‘%%@%1’ in the SELECT statement. Instead, the run-time CONCAT function is used. The single quotes surrounding the first parameter, ‘%%@’, must be doubled because the entire SELECT statement is inside a quoted string. LISTSERV will supply the quotes around the %1 parameter.
Note: All of the quote marks used in these examples are true single quotes (ASCII hex 27), also called apostrophes. Do not use smart quotes or double quotes in these queries.