Calgary Queries

Queries allow any number of fields to be selected.  All fields selected in a query must have an Index built for them.

Queries can be any mixture of ANDs and ORs.  And given field can specify any number of values or a begin/end range.  In this case it will be an OR within the field.  There is no limit to the depth of ANDs and ORs.

Query Types

  • And & Or: These groups can contain any number of Field or SpatialField elements or additional And or Or elements.
  • Not: Can contain exactly one And, Or, Field, or SpatialField element.  The selection will be reversed from what is inside, i.e. if inside you have Gender="M", it will return all genders except M (including NULL and otherwise invalid values).  If there is more than 1 child element, it will be an error.
  • All:  Special tag that selects all records.
  • Field: The Field element has a required attribute name which is the field name for this query.  

Attribute types

For all index types except spatialObject the attribute type can have the following values:

value (Default): A single exact value will be search for.  If no type is specified, it will be presumed to be value.  The value attribute or the value of the element will contain the value.

delayedValueNum:  Used in place of value if you will be setting a value later with CalgarySetDelayedValue (found in the Calgary API).  Can be used to speed up repeated queries.

list: The value attribute or the value of the element will contain a comma separated list of values to query on.  If escaping is needed, the each element of the list can be placed within <value>..</value> tags.  Value tags are only valid if using list.  If not, use the value attribute or the value of the parent element.  If using the value tags, the other methods must not be set.

range: There are two additional attributes begin and end that contain the end points.  By default it will find value>=begin AND value<end.  Optionally includeBegin="True/False" includeEnd="True/False" can be specified to change this behavior.  

If leaving the begin or end attribute out or setting it to an empty string, that becomes unbounded.