19. Intrinsic Function Reference

FileFlex defines 12 functions that you can use in DBSeek and DBQuery logical expressions.

Intrinsic Functions for DBSeek and DBQuery

The following functions can be used in either DBSeek or DBQuery expressions:

Intrinsic Functions for DBQuery Only

The following functions can be used in DBQuery expressions only: The IFF function described above allows you to nest logical conditions with one DBQuery call. For example, you might design a credit collection and management system with the requirement that each customer file has not only a credit limit, but also a description of when you wish to take some collection action. The credit limit might be stored in a field called LIMIT and the action description in a field called COLLECT. This would enable you to establish different collection policies for each customer. You might use a line something like this:
  put DBQuery("COLLECT = IFF(LIMIT>10000,'Casual',' '")
      into dbResult
This would confine your database review to records where the field COLLECT had a value of "Casual" and the LIMIT field is greater than $10,000. In other words, it would allow you to examine all casual customers with high credit limits.

Logical Operators (DBQuery Only)

Within the DBQuery expression, you can join functions, constants, and field names with logical operators. There are two types of such operators: comparative and connective.

The comparative operators recognized by FileFlex are shown below. Except for the "$" operator, they are the "standard" comparative operators recognized by many major database systems and programming languages. The "$" operator tests for the presence in one string of another (e.g., "ABC" $ "ABCDEF" returns .TRUE.).

Comparative Operators
SYMBOL             INTERPRETATION
  =                equal to
  <>               not equal to
  <                less than
  <=               less than or equal to
  >                greater than
  >=               greater than or equal to
  $                is contained in
The connective operators recognized by FileFlex are the same as those understood by dBASE: .NOT., .OR., and .AND. Note that, like the .TRUE. and .FALSE. constants mentioned earlier, these operators must be surrounded by periods to avoid their being confused with strings of characters.

These connective operators can be combined with the logical operators above to create some fairly complex search criteria. For example, if you wanted to find all your customers in California or Arizona with low account balances and who had received your catalog, you might end up with an expression like this:
  DBQuery("(State='CA' .OR. State='AZ') .AND. 
           Balance<=1000 .AND. Cat=.T.)") 

String Constants in DBQuery Expressions

FileFlex defines a special string constant operator used within the DBQuery expressions. The string operator is the single quote (') -- make sure you don't use "smart quotes". When you call DBQuery, you always need to pass it a string containing the search expression. This is string according to the rules of your host development environment. But when you're comparing the state to 'CA', as in the above example, you're passing a DBQuery string to the function. In this case, the string you're asking DBQuery to compare within the expression must be surrounded by single quotes.



  [Previous Chapter]    [Table of Contents]    [Next Chapter]


Copyright (c) 1996 David Gewirtz under license to Component Software Corp. All rights reserved worldwide.