home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
DATABASE
/
ZMAIL389.ZIP
/
QUERY.DOC
< prev
next >
Wrap
Text File
|
1990-11-02
|
10KB
|
251 lines
Explanation of Query Builder:
The query builder allows you to define a condition which a record must
meet in order for the record to be included in the filter. While the
query is active, only the records that meet the condition you have
specified will be presented for viewing, editing, printing, etc. The
other records in your database are still there, but they are temporarily
filtered out. When the filter is turned off, all your records are
available for use again.
When you select the query builder, you will be presented with the following
menu:
Build a new Query
Add to current query
Count matching records
Zap (remove) existing Query
Save current Query to disk
Restore Query from disk
Delete stored queries
What is current Query
Edit current Query
View records matching Query
Quit
Here is how to build a query:
When you select Build a new Query, you will be presented with a list of
the fields in the database you are working with. Here is an example:
Database Field List
< Deleted? >
ITEM
AMOUNT
DATE
CHECK_NO
TO
CATEGORY
COMMENTS
OK
MEMO
Place the lite bar over the field you want, and press Enter to select
the field.
Note: the Deleted option allows you to work with records you may have
marked for deletion but have not yet purged from the database. (Records
may be marked for deletion while in the browse (Use) mode. Records marked
for deletion may be purged with option C on the Services menu.)
When you select a field, you will be asked if you wish to further define
the field you have selected. You will be asked something like:
Extend field ITEM with EXPRESSION BUILDER ?
No Yes
The default answer in No. In most cases, this is what you will want. If
you have some particular need to further refine the selection of data in
the field you have chosen, you can answer Yes.
If you answer Yes, you will be presented with a menu of choices
appropriate to the type of field you have selected, i.e., character,
numeric, date, logical, or memo field.
Here are the choices if the field type is character:
E X P R E S S I O N B U I L D E R
QUIT and return current expression
TEST against database (WYSIWYG)
UNDO last change
HELP help with expression builder
EXTRACT subset or rearrange
JUSTIFY left right centered
CASE uppercase lowercase proper
MOVE spaces to end of string
ADD or imbed characters
SUBSTITUTE one value for another
DIFFERENT change to date or numeric
Select QUIT to leave the expression builder.
Select TEST to test your expression against the current database.
Select UNDO to undo your most recent change while using the expression
builder.
Select HELP for brief help on using the expression builder.
Select EXTRACT if you wish to work with only those records that contain a
desired portion of the data in the character field. For example, assume
the character field you have selected contains a ten character code, and
you want to work with only those codes that contain A99 in the first
three spaces. You could select EXTRACT, then Left 3 characters on the
next screen. The query expression would become LEFT(ITEM,3).
After Quitting to the next screen, you would specify EXACTLY EQUAL TO,
and then A99. If you then Viewed records matching the Query, you would
see only records which contained A99 in the first three spaces of the
item code field.
When you return to the main menu, the query expression will be displayed
in the Status box at the bottom of the screen to remind you that the only
records that are active are those which meet the query expression. You
can toggle the filter (query expression) off by selecting Filter again
from the main menu when you are finished working with the A99 records.
Select JUSTIFY if you wish the right justified, left justified, or
centered field data to match some value you are going to specify. An
example of a situation in which you might use this capability would be
where you suspect blank spaces might have been entered in the field,
e.g., " A99" instead of "A99". By specifying left justified here, and
specifying EXACTLY EQUAL TO A99 at the next screen, you will get all the
A99 records, even those where blanks might have been entered by mistake
at the beginning of the field data.
Select CASE if you wish the upper-cased, lower-cased, or properized
(first letter capitalized) field data to match some value you are going
to specify in the next step.
Select MOVE to move all spaces, or all but single spaces to the end of a
string. For example:
"Merry Christmas to all" becomes "Merry Christmas to all " if you move
all but single spaces to the end, and "MerryChristmastoall " if you
move all spaces to the end.
Select ADD if you wish to add or imbed particular characters in the query
expression in order to compare that expression to some value you
will specify in the next step.
Select SUBSTITUTE if you want to have the filter substitute one string of
characters for another string so that appropriate matching can take place
against some value you will specify in the next step.
Select DIFFERENT if you wish to have the filter convert characters to
numeric or date format so that appropriate matching can take place
against some value you will specify in the next step.
___
Other appropriate options for expression building are presented when you
select a numeric, date, logical, or memo field.
The basic idea is that the expression builder allows you to further
define the field data you want to match some value you are going to
specify in the next step.
___
Whether you have used the Expression Builder or not, the next step in
defining your query is presented with the following menu if the field you
are working with is a character field:
= (EXACTLY EQUAL TO)
<> (NOT EQUAL TO)
< (LESS THAN)
> (GREATER THAN)
<= (LESS THAN OR EQUAL TO)
>= (GREATER OR EQUAL TO)
$ (CONTAINS)
!$ (DOES NOT CONTAIN)
?* (WILDCARD MATCH)
S (IS SIMILIAR TO)
B (BEGINS WITH)
E (ENDS WITH)
What you are being asked to do here is to tell the query builder how you
want the field data (or the expression you defined in the expression
builder) to be compared to some value.
For example, if the field you selected is LASTNAME, you can tell the
query builder here that the field contents must be exactly equal to
SMITH, that the field contains JONES, that the field contents begin or
end with some value, etc.
Similar appropriate options for field content comparisons are presented
when you select a numeric, date, logical, or memo field.
___
When you have finished defining the query expression for the field you
selected, you will be presented with the following choices:
DONE
AND
OR
AND NOT
OR NOT
If you are done, select DONE and you will be returned to the main query
builder menu. If you wish to include other field specifications in the
query expression, you can select one of the other options, as
appropriate, and repeat the same procedure as above.
For example, say your query expression at this point is something like
LASTNAME = "SMITH", and you wanted to work with only those SMITH's who
live in California. Assuming your database contains a two character STATE
field, you would:
1. select AND instead of DONE.
2. select STATE from the field list.
3. select EXACTLY EQUAL TO or CONTAINS (CONTAINS is often better)
4. enter CA for the state name.
5. select DONE.
Your query expression now contains the appropriate references to both
fields.
___
When you have created your query expression, Query Active will flash on
the screen. You can now Quit the query builder and return to the main
menu, or select another option from the query builder menu.
If you Quit, you will return to the main menu where the query expression
will be displayed in the Status box at the bottom of the screen to remind
you that the only records that are active are those which meet the query
expression. You can toggle the filter (query expression) off by
selecting Filter again from the main menu.
___
The other query builder menu options are fairly self-explanatory.
One of these options, Edit current Query, allows you to modify the query
expression yourself. Any valid dBase or Clipper function may be used. For
example, if you wanted to specify the trim (field data stripped of any
trailing blanks) of a character field called LASTNAME, you could edit the
query expression to include TRIM(LASTNAME).
For a full listing of such functions, please refer to your dBase manual,
Clipper manual, or any of the many reference books on this subject.
___End.