One of the big advantages to using RETS over a different delivery method (such as FTP) is the ability to tell the server specifically which records you'd like to be returned. In order to do this, a query language called DMQL (or, more recently, DMQL2) is used that defines the structure of search conditions that you send to the server.
DMQL is made up of simple name-value pair conditions passed as part of the requested URL in RETS. By passing in requested conditions, you can limit what types of records you get back in real-time.
Name-value conditions are passed with each surrounded in parentheses. For example:
To pass multiple conditions, each is separated by a comma (see Operators below for more information about separators). This will only return records where name1 is equal to value1 and name2 is equal to value2:
You can also search a single field for multiple values. For example, the below returns records that match 1) name1 is value1a or value1b or value1c, and 2) name2 is value2:
The name part is either the SystemName (when requesting StandardNames use as false, default) or the StandardName (when requesting StandardNames use as true) defined for the field.
The value part is made up of searchable patterns as described in the sections below.
In RETS, the condition value allows for special characters depending on the type of field being searched. For Character fields, you're able to use wildcard characters that allow you to find character patterns in a field.
Example: where 'name' field starts with 'value'
Example: where 'name' field contains 'value'
Example: where 'name' field starts with either 'value' or 'other'
Example: where 'name' field equals 'val?e' where ? represents a single character
In RETS, the condition value allows for special characters depending on the type of field being searched. For Tiny, Small, Int, Long and Decimal fields, you're able to use special characters to indicate ranges of numbers.
Example: where 'number_field' is greater than or equal to 2
Example: where 'number_field' is less than or equal to 5
Example: where 'number_field' is between 2 and 4 (including 2 and 4)
In RETS, the condition value allows for special characters depending on the type of field being searched. For Date, DateTime and Time fields, you're able to use special characters similar to Numeric fields (see above) to search for ranges of dates and times.
For Date fields, the value must be sent in YYYY-MM-DD format.
For Time fields, the value must be sent in HH:MM:SS format.
For DateTime fields, the value must be sent in YYYY-MM-DDTHH:MM:SS format (Date and Time separated by a 'T').
Example: where 'date_field' is on or after 2009-01-01
Example: where 'date_field' is on or before 2009-01-01
Example: where 'date_field' is between 2009-01-01 and 2009-01-25 (including 2009-01-01 and 2009-01-25)
Example: where 'datetime_field' is on or after 2009-01-01T00:00:00
Timezones and GMT conversion
When requesting records based on a Date or Time, the value you send must be converted to GMT. This ensures that the server knows exactly what timeframe you're interested in querying for since your local timezone information isn't available to the RETS server. The server will read your GMT date/time and will convert that back to it's local timezone in order to run queries on the data.
Also, note that dates and times you receive back from the RETS server will NOT be converted back to GMT time.
The examples below demonstrate some common queries done with a RETS server. The following describes the fields being used in the examples (see the metadata information available from the RETS server for specific field names you can use):
|System Name||Description||Field Type||Example Value|
|LIST_15||Status||Character (lookup)||(see below)|
|Possible values of LIST_15 (Status)|
All records that have been modified on or since 2009-02-01T00:00:00 GMT
All records that have at least 2 pictures and costs $179,000 or less
All records that have 4 pictures on either Main St. or West St.
All records that have a status of "Active"
All records that have a status of either "Active" or "Pending"