The sqltest tag inserts a condition test into SQL code. It tests a
column against a variable. This tag is used in SQL Methods.
sqltest tag syntax:
<dtml-sqltest Variable|expr="VariableExpression">
The sqltest tag is a singleton. It inserts a SQL condition test
statement. It is used to build SQL queries. The sqltest tag
correctly escapes the inserted variable. The named variable or
variable expression is tested against a SQL column using the
specified comparison operation.
string, int, float and nb. nb means non-blank string,
and should be used instead of string unless you want to test for
blank values. The type attribute is required and is used to
properly escape inserted variable. The comparison defaults to equal to. If the comparison is not
recognized it is used anyway. Thus you can use comparisons such
as like.
Basic usage:
select * from employees
where <dtml-sqltest name type="nb">
If the name variable is Bob then this renders:
select * from employees
where name = 'Bob'
Multiple values:
select * from employees
where <dtml-sqltest empid type=int multiple>
If the empid variable is (12,14,17) then this renders:
select * from employees
where empid in (12, 14, 17)