DBQuery -- Search records against query expression |
DBQuery(query-expression) |
Retrieving Information |
THIS FUNCTION HAS CHANGED IN FILEFLEX 3.0 DBQuery performs an iterative scan of records looking for a match against the query expression. DBQuery has changed considerably since FileFlex 2.0. It no longer uses DBSkip to travel through matches. It also does not perform a DBTop to go to the head of the database. Instead, DBQuery scans from the current record using the internal active skip mechanism (meaning index order, if active) until it finds a match. To continue a subsequent DBQuery (for the next match), you'll first need to do a DBSkip(1) to move to the next record or DBQuery will again check the current record. Any subsequent DBQuery calls with different expressions will continue from where the last left off. This allows for refinements on an indexed search (no, you can't stack seeks), and weird, funky, iterative query scans. DBQuery will locate a record based on the contents of one or more database fields for which you do not have an index or for which you do not wish to use the index file for some reason (e.g., you want to perform a complex query), you can use the DBQuery function. The DBQuery function takes a single argument, which must be either a string or a container that holds a string. The string must evaluate to a logical expression (i.e., one that can be True or False). Generally, these expressions are strings that contain the name of a database field, a comparison operator (=,>,<,<>, etc.) and a value to be compared. For example, this line: put DBQuery("sales > 50000") into dbResult will set up a search condition which tells FileFlex that you only want to see records where the value in the database field called "sales" exceeds $50,000. You can combine search terms using logical connections (.AND., .OR., and .NOT.). For example, to find records where sales are more than $50,000 and the customer is located in Michigan, you could use a line like this: put DBQuery("sales > 50000 .AND. state='CA'") into dbResult The expression parser in DBQuery recognizes some new functions. These new functions are also available in relational queries and indexed searches. The new functions are:
|
DBSeek, DBSkip |
35
|