SQLWhereItems property

Applies to
TIB_Dataset

Declaration
Property SQLWhereItems : TStrings;

Description
This property is very useful for having IBO handle the parsing of items to be added to the WHERE clause of the SELECT statement being constructed. It is only valid to add items to this string list during the OnPrepareSQL phase.

Each entry must be a unit that returns a boolean true or false and be valid SQL syntax. It is possible to use parenthesis which will provide nesting of items. By default all items are AND'd together but the OR operator can be placed by iteslf as an item and it will serve as an operator.

Here are some sample uses of this property:
SQLWhereItems.Add( '(' );
SQLWhereItems.Add( 'MYCOL1 = 100' );
SQLWhereItems.Add( 'OR' );
SQLWhereItems.Add( 'MYCOL1 = 200' );
SQLWhereItems.Add( ')' );


and when parsed into the finalized SQL statement will end up as:

WHERE .... < original criteria plus other system stuff >
AND ( MYCOL1 = 100 OR MYCOL1 = 200 )

This may seem simple and of little use but it will make it much easier to
build the SQL criteria when combining the logic of numerous controls that
impact the statement.

It is possible to nest the parenthesis and if an operator is ommitted AND is
used as the default. For example:
SQLWhereItems.Add( '(' );
SQLWhereItems.Add( '(' );
SQLWhereItems.Add( 'MYCOL = 100' );
SQLWhereItems.Add( 'MYCOL = 200' );
SQLWhereItems.Add( ')' );
SQLWhereItems.Add( 'MYCOL = 300' );
SQLWhereItems.Add( ')' );


when parsed into the finalized SQL statement will end up as:

WHERE ....
AND (( MYCOL = 100 AND MYCOL = 200 ) AND MYCOL = 300 )