Progress
Language Tutorial
for Character
Selecting with a WHERE Expression
Any valid Progress expression can be used with WHERE to select records. The code fragment below shows an example:
In addition to the expressions you learned about in "Working with Expressions," WHERE supports operators that make working with CHARACTER data easier:
This example of BEGINS finds any record where the field reference begins with the same letters as specified in the option:
The output from this selection criteria includes Smith, Smithers, Smithy, and so on.
This example of MATCHES finds any record where there is an exact match between the supplied string and the database field reference:
This example finds Tim. However, MATCHES is very slow compared to using BEGINS. In most cases, substituting the = operator is far more efficient than using MATCHES.
You can use two wildcards with the MATCHES options, and this is the only use where MATCHES has an advantage over the other comparison operators. Use asterisk (*) to take the place of many characters and period (.) to take the place of a single character as shown in the following example:
This example finds Tam, Tim, and Tom. Remember, do not use MATCHES unless there is no other way to write the expression with another operator. The most common use of MATCHES is to search for an expression that begins with a wildcard. For example "*berry". This example would find Strawberry, Blueberry, Raspberry, and so on in a list of fruits.
NOTE: You can use BEGINS and MATCHES in any CHARACTER expression.When a field is defined as a word index in the database schema, you can use the CONTAINS option. CONTAINS checks whether the supplied string is contained anywhere in the field reference. Review the following code example that presents the CONTAINS option:
If any of the comment fields contains the specified string, it is selected.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |