KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Using a Project Method with QUERY BY FORMULA
PRODUCT: 4D | VERSION: 6.5 | PLATFORM: Mac & Win
Published On: August 31, 2001
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

When using the command QUERY BY FORMULA or QUERY SELECTION BY FORMULA, you can perform sophisticated record analysis by placing a call to a Project Method in the queryFormula parameter instead of just using a 4D expression. For example:

QUERY BY FORMULA([theTable]; mySpecialQuery)


The method specified ('mySpecialQuery' in the above example) must return a Boolean result which indicates whether the record should be included in the found set or not.


` Project Method: mySpecialQuery



IF (([theTable]field1="DPTA@") & ([theTable]field2>100))

 $0:=True ` the record meets our criteria

ELSE

 $0:=False ` the record should be excluded

END IF


Note that QUERY BY FORMULA and QUERY SELECTION BY FORMULA are slower than a regular QUERY when used on indexed fields, because they always perform a sequential search not an indexed search (i.e. every record must be loaded and tested in turn).