|
|
The
filter
argument refers to an object, object literal, or string
specifying a subset
of table records that will be effected by the specified
operation. The filter
parameter specifies column names corresponding to columns
in the table schema, and values corresponding to the desired
values for each respective field name.
The
filter
argument does not have to specify every column in the
schema; behavior for omitted columns depends on which
method is being called. The filter string "*" indicates
that the operation should be applied to all records in
the specified table. A missing filter argument always
generates a runtime error. An exception is thrown if a
specified column name is not found.
Filters may be specified in one of the following three ways:
1. |
Using an object:
var filt = new object();
filt.FieldA = "ValueA";
filt.FieldB = "ValueB";
var rs = new Resultset("MyTable", "FieldA, FieldB", filt);
|
2. |
Using
an object literal:
var rs = new Resultset("MyTable",
"FieldA, FieldB", {FieldA:"ValueA", FieldB:"ValueB"});
|
3. |
The following examples demonstrate string filters in conjunction with SQL expressions. They can appear as filter arguments for table related methods in script or be entered in the Filter Preset wizard in the Properties tab of the Design View of a data table's View file.
The following Resultset uses a SQL expression to filter those records where FieldA has the value ValueA and FieldB has the value ValueB.
var rs = new Resultset("MyTable", "FieldA, FieldB",
"FieldA='ValueA' AND FieldB='ValueB' ");
The following example uses a SQL function to filter for those orders which were filled 10 days after they were ordered, i.e., it filters for records where the ShippedDate field is 10 or more days after the OrderedDate field.
var rs = new Resultset("MyTable", "OrderedDate, ShippedDate",
"datediff(day, OrderedDate, ShippedDate) > 10");
|
For more information on specifying string filters with SQL expressions, see Filtering Views and the SQL Expressions Reference.
Filtering on File Attachment and URL fields
When filtering on File Attachment and URL fields, note that these fields store paths to files. As a result, filters on these fields should refer to paths. For example, to filter for the file "myFile.gif" in a File Attachment field called "myAttachmentField", make reference to the path to "myFile.gif" in the filter parameter.
var filt = "myAttachmentField='/myDataTable/files/myAttachmentField/myFile.gif'";
var rs = new Resultset("myDataTable", "myAtachmentField", filt);
|