Skip to content
Carlo Barazzetta edited this page Dec 6, 2018 · 6 revisions

**The Selector component **

The TInstantSelector is a dataset component that allows you to select objects from the database and optionally expose them in the user interface. To select objects from the database, a command must be specified in the Command property. The syntax of this command (called an IQL command, from Instant Query Language)  is somewhat similar to an SQL SELECT-statement, but instead of tables and columns, you specify classes and attributes:

SELECT [DISTINCT] *|<Attribute>
FROM [ANY] <Class>
[WHERE <Expression>]
[ORDER BY <Attribute list>]

The simplest command that can be specified looks like this:

SELECT * FROM TContact

This command selects all concrete instances of the class TContact. Toselect instances of TContact and any descendant class, add the ANYkeyword:

SELECT * FROM ANY TContact

If you want to select objects that are related to instances of a class,specify the relation attribute instead of the *, like this:

SELECT Address FROM ANY TContact

If the same object is related to from several objects via the specifiedattribute and you do not want it to appear more than once in the result,use the DISTINCT keyword with the attribute:

SELECT DISTINCT Address FROM ANY TContact

To select from objects that meet a certain criteria, you must add aWHERE clause to the command. This clause must contain an expression thatevaluates to True or False. The expression can use attributes, constantsand functions in combination with the most common operators. Thefollowing example will select all customers with a negative balance.

SELECT * FROM TCustomer WHERE Balance < 0

To order the selected objects by one or more attributes, specify theattributes with ORDER BY:

SELECT * FROM TCustomer ORDER BY Balance, Name

When the selector is opened, it performs a query against the database.The resulting objects are available via the Objects property. The numberof objects selected can be read via the property ObjectCount. If you want to expose the selected objects in the user interface, simplyassign the selector to a TDataSource that is attached to data-awarecontrols.

Clone this wiki locally