The front-end to all Inquiries, Reports and Lookups is a Query By Example Screen. Query By Example is a convenient and efficient way for the user to affect the way the program selects data to be processed, without any reprogramming. For instance, the Supplier Reference Listing is a program designed to print out all suppliers in the Supplier Reference File. Suppose one of the officers of the company needs to find out the names of all the suppliers thatŐs giving a Trade Discount of 5%. The traditional way of doing this is have the programmer go back to the drawing board and write another program to specifically fulfil this request. This is not an efficient solution. A better alternative is to use Query By Example. With Query By Example, the company officer could just enter the trade discount code into the Discount Reason field, 5 on the Discount Percent Field and execute the report. Viola! The report will just print all suppliers with a 5.00% trade discount.
Query By Example lets the user enter a value or a set of matching values from the query screen which the computer will use as parameters for searching the database. The program will analyze the query screen and dynamically generate the search criteria. The value entered in the query screen field is converted into a Boolean expression that is used in the search criteria. Think of the Query By Example as a sort of filtering command for the database. When the nothing is specified, all records are selected. When values are entered, then all rows matching the values are selected.
Entering "ACME CORPORATION" on the supplier name field of the supplier reference listing query screen means the user wants the computer to locate this supplier, if it exists. On character fields, the wildcard '*' is valid. It will match zero or more characters. Entering "ACME*" in the supplier name of the query screen will bring up all supplier whose name begins with "ACME" such as "ACME CORPORATION", "ACMETECH CORPORATION" and "ACMETRADE MFG".
The following symbols are valid in character string fields:
The user should refrain from using the following relational symbols as part of the Query By Example value: " : < > |. Unexpected errors will occur when one of these relational symbols are embedded in the Query By Example field..* - Character string wildcard. It matches zero or more characters. ? - Single-character wildcard. It matches any one character. [ ] - Match a list of characters in the bracket. ^ - As the first character in the bracket, it matches any character not listed. - - A hyphen between characters within the brackets specifies a range.
The following keys are valid on the Query By Example screen:
FKEY9 - valid on some fields lookup fields. TAB - moves to the first field of the next group. BackTAB - moves to the first field of the previous group. Down Arrow - moves to the next field Up Arrow - movers to the previous field. CTRL-X - clears any data on the screen, if there's any, otherwise it works as the Exit key. F4 - Exit program. F6 - printer selection menu. This key works only on report programs. F7 - preview mode toggle. This key works only on report programs. F1-F16 - Execute the Query by Example front end as dictated by the prompt.
On some Query By Example columns, the entry is split up into 3 separate fields: expression1, relational-operator, and expression2. This allows the user to specify a wider range of Query Conditions.
The expression1 and expression2 fields are where the user would specify the Query Examples. The relational-operator field is specify the affects of the operation of the Query Examples. The following table show the valid relational-operators and their resulting Query Conditions:
| Relational Operator |
Operation |
Query Condition |
|---|---|---|
| Range | BETWEEN expression1 AND expression2 | |
| Or | expression1 OR expression2 | |
| Not Equal | NOT EQUAL TO expression2 | |
| Less Than | LESS THAN expression2 | |
| Greater Than | GREATER THAN expression2 | |
| Less Than or Equal To | LESS THAN OR EQUAL TO expression2 | |
| Greater Than or Equal To | GREATER THAN OR EQUAL TO expression2 | |
| IN Values | IN values given | |
| NOT IN Values | NOT IN values given | |
| IN Sub-Query Set | IN (SELECT colname FROM xsqstd...) | |
| NOT IN Sub-Query Set | NO IN (SELECT colname FROM xsqstd...) | |
| IS NULL | colname IS NULL | |
| IS NOT NULL | colname IS NOT NULL |
After a + or - is entered on the relational-operation field, an input line will appear on the bottom of the screen. You can then enter multiple values separated by commas. The resulting SQL Statement will be an IN or NOT IN clause with the entered values as the parameters.