Adds a comparison operand to the node.
The operand created by this method consists of a field name, a comparison operator, and a value. When the query is run, the value in the field is compared to the specified value using the given comparison operator. The comparison yields a Boolean value, which the node uses in its own Boolean comparison.
The value argument is a Visual Basic Variant or Perl reference to an array of strings to allow you to specify an array of values when appropriate. For example, if you wanted to find the defects submitted between December 1 and December 15, 2000, you could construct the following filter:
@dateRange = ("2000-12-01", "2000-12-15"); $node->BuildFilter("submit_date", $CQPerlExt::CQ_COMP_OP_BETWEEN, \@dateRange);
See also the example given for QueryDef's BuildFilterOperator method.
Query expressions are not limited to being binary trees; you can call this method as many times as you want for a given QueryFilterNode object.
To obtain valid values for the field_name argument, call the GetFieldDefNames method of the EntityDef object upon which the query was based.
VBScript
node.BuildFilter field_name, comparison_operator, value
Perl
$node->BuildFilter(field_name, comparison_operator, value);
In Visual Basic, specify the value as a Variant or Variant array.
In Perl, specify the value as a reference to a string or an array of strings.
VBScript
Dim dateRange ReDim dateRange(1) ' This sets up a two element array dateRange(0) = "2000-12-01" dateRange(1) = "2000-12-15" node.BuildFilter "submit_date", AD_COMP_OP_BETWEEN, dateRange
Perl
#Example1
@dateRange = ("2000-12-01", "2000-12-15");
$node->BuildFilter("submit_date", $CQPerlExt::CQ_COMP_OP_BETWEEN,
\@dateRange);
#Example2
@owner = ("jsmith");
@state = ("closed");
$queryDef = $CQsession->BuildQuery("defect");
@dbfields = ("ID","State","Headline");
foreach $field (@dbfields) {
$queryDef->BuildField($field);
}
$operator=$queryDef->BuildFilterOperator($CQPerlExt::CQ_BOOL_OP_AND);
$operator->BuildFilter("Owner", $CQPerlExt::CQ_COMP_OP_EQ,\@owner);
$operator->BuildFilter("State", $CQPerlExt::CQ_COMP_OP_NOT_IN, \@state);