SELECTING
From CometWiki
(New page: SELECTING Syntax: SELECTING [IF] field-name relational-operator value [AND field-name relational-operator value] Where: Relational-operators: EQ = equal to NE = not equal to ...) |
|||
Line 1: | Line 1: | ||
- | SELECTING | + | |
- | Syntax: SELECTING [IF] field-name relational-operator value [AND field-name relational-operator value] | + | == SELECTING == |
- | Where: | + | |
+ | '''Syntax:''' <br> | ||
+ | SELECTING [IF] field-name relational-operator value [AND field-name relational-operator value] | ||
+ | '''Where:''' | ||
+ | Relational-operators: | ||
EQ = equal to | EQ = equal to | ||
NE = not equal to | NE = not equal to | ||
Line 11: | Line 15: | ||
(CONTAINS introduced with UTL vsn. 8) | (CONTAINS introduced with UTL vsn. 8) | ||
- | Logical operators: | + | Logical operators: |
AND = as shown above | AND = as shown above | ||
OR = implied with multiple SELECTING statements | OR = implied with multiple SELECTING statements | ||
- | Placement: Place the SELECTING command before or after the REPORT command. If used in conjunction with a SORT command, it must appear before the SORT command. | + | '''Placement:''' <br> Place the SELECTING command before or after the REPORT command.<br> If used in conjunction with a SORT command, it must appear before the SORT command. |
- | Discussion: The SELECTING command allows you to specify the records from you primary or secondary file(s) that contain the data you wish to use for your report. SELECTING tells The Reporter to restrict the data to just those records that meet the criteria you specify. The field-name parameter is the name of the field you wish to quantify; the relational-operator is one of the comparative operators listed above; and the value is either a constant on another field within the file. | + | |
+ | '''Discussion:''' The SELECTING command allows you to specify the records from you primary or secondary file(s) that contain the data you wish to use for your report.<br> SELECTING tells The Reporter to restrict the data to just those records that meet the criteria you specify. <br> The field-name parameter is the name of the field you wish to quantify;<br> the relational-operator is one of the comparative operators listed above;<br> and the value is either a constant on another field within the file. | ||
+ | |||
If you do not include a SELECTING command in the report, all the records in the file and used for the report. | If you do not include a SELECTING command in the report, all the records in the file and used for the report. | ||
- | Line continuation | + | '''Line continuation''' |
To continue a SELECTING command to the next line, end the first line with "AND" and continue on the next line. | To continue a SELECTING command to the next line, end the first line with "AND" and continue on the next line. | ||
- | Examples: A simple example of a SELECTING statement is: | + | '''Examples:''' A simple example of a SELECTING statement is: |
SELECTING IF PREVIOUS.YTD GT 1000.00 | SELECTING IF PREVIOUS.YTD GT 1000.00 | ||
Line 30: | Line 36: | ||
SELECTING IF CUST.NAME CONTAINS "shop" | SELECTING IF CUST.NAME CONTAINS "shop" | ||
- | The above clause would match customer names such as "The Computer Shoppe", "Shopper's Paradise", and "Stop 'N Shop". | + | The above clause would match customer names such as "The Computer Shoppe", "Shopper's Paradise", and "Stop 'N Shop". <br> |
- | To qualify the data on more than one set of criteria, the logical operations "AND" and "OR" can be used. An OR condition says if one or the other selecting conditions is true, print the data. | + | To qualify the data on more than one set of criteria, the logical operations "AND" and "OR" can be used. <br> An OR condition says if one or the other selecting conditions is true, print the data. |
An OR condition is implied by separate SELECTING statements. For example: | An OR condition is implied by separate SELECTING statements. For example: | ||
Line 39: | Line 45: | ||
SELECTING IF ZIP.CODE EQ 90090 | SELECTING IF ZIP.CODE EQ 90090 | ||
- | This series of SELECTING statements would print any customer with a ZIP code of 90010, 90060, or 90090. | + | This series of SELECTING statements would print any customer with a ZIP code of 90010, 90060, or 90090.<br> |
To set up AND conditions, the word AND must be used between the sets of conditions. For example: | To set up AND conditions, the word AND must be used between the sets of conditions. For example: | ||
SELECTING IF AR.OVER.90 NE 0 AND STATE EQ "CA" | SELECTING IF AR.OVER.90 NE 0 AND STATE EQ "CA" | ||
- | This statement would select any customer who had invoices due over 90 days and was in the state of California. | + | This statement would select any customer who had invoices due over 90 days and was in the state of California. <br> |
- | Fields in the SELECTING statement may be numeric or string type fields. When using a string compare, any constant value must be enclosed in quotes. Another important consideration in comparisons on string fields is that when an equal comparison is required, you must be aware of the actual size of the string field and possibly pad your string comparison with blanks. | + | Fields in the SELECTING statement may be numeric or string type fields.<br> When using a string compare, any constant value must be enclosed in quotes. <br> Another important consideration in comparisons on string fields is that when an equal comparison is required, you must be aware of the actual size of the string field and possibly pad your string comparison with blanks. |
- | For example, many applications use a three-character state code, using the 3rd position as a special indicator to the application program. If you want to find all the customers in California, for example, you would use the following SELECTING statements: | + | For example, many applications use a three-character state code, using the 3rd position as a special indicator to the application program.<br> If you want to find all the customers in California, for example, you would use the following SELECTING statements: |
SELECTING IF STATE EQ "CA " | SELECTING IF STATE EQ "CA " | ||
SELECTING IF STATE EQ "CA+" | SELECTING IF STATE EQ "CA+" | ||
- | Using both SELECTING statements constitutes an "OR" condition, so all customers with "CA " or "CA+" in the STATE field would be reported. If you merely requested | + | Using both SELECTING statements constitutes an "OR" condition, so all customers with "CA " or "CA+" in the STATE field would be reported.<br> If you merely requested |
SELECTING IF STATE EQ "CA" (no trailing blank) | SELECTING IF STATE EQ "CA" (no trailing blank) | ||
there would be no records selected for the report. | there would be no records selected for the report. |
Latest revision as of 10:52, 6 June 2009
SELECTING
Syntax:
SELECTING [IF] field-name relational-operator value [AND field-name relational-operator value]
Where:
Relational-operators: EQ = equal to NE = not equal to LT = less than LE = less than or equal to GT = greater than GE = greater than or equal to CONTAINS = contains string value anywhere in the field (case insensitive) (CONTAINS introduced with UTL vsn. 8) Logical operators: AND = as shown above OR = implied with multiple SELECTING statements
Placement:
Place the SELECTING command before or after the REPORT command.
If used in conjunction with a SORT command, it must appear before the SORT command.
Discussion: The SELECTING command allows you to specify the records from you primary or secondary file(s) that contain the data you wish to use for your report.
SELECTING tells The Reporter to restrict the data to just those records that meet the criteria you specify.
The field-name parameter is the name of the field you wish to quantify;
the relational-operator is one of the comparative operators listed above;
and the value is either a constant on another field within the file.
If you do not include a SELECTING command in the report, all the records in the file and used for the report.
Line continuation
To continue a SELECTING command to the next line, end the first line with "AND" and continue on the next line.
Examples: A simple example of a SELECTING statement is:
SELECTING IF PREVIOUS.YTD GT 1000.00
Here's an example using the CONTAINS operator:
SELECTING IF CUST.NAME CONTAINS "shop"
The above clause would match customer names such as "The Computer Shoppe", "Shopper's Paradise", and "Stop 'N Shop".
To qualify the data on more than one set of criteria, the logical operations "AND" and "OR" can be used.
An OR condition says if one or the other selecting conditions is true, print the data.
An OR condition is implied by separate SELECTING statements. For example:
SELECTING IF ZIP.CODE EQ 90010 SELECTING IF ZIP.CODE EQ 90060 SELECTING IF ZIP.CODE EQ 90090
This series of SELECTING statements would print any customer with a ZIP code of 90010, 90060, or 90090.
To set up AND conditions, the word AND must be used between the sets of conditions. For example:
SELECTING IF AR.OVER.90 NE 0 AND STATE EQ "CA"
This statement would select any customer who had invoices due over 90 days and was in the state of California.
Fields in the SELECTING statement may be numeric or string type fields.
When using a string compare, any constant value must be enclosed in quotes.
Another important consideration in comparisons on string fields is that when an equal comparison is required, you must be aware of the actual size of the string field and possibly pad your string comparison with blanks.
For example, many applications use a three-character state code, using the 3rd position as a special indicator to the application program.
If you want to find all the customers in California, for example, you would use the following SELECTING statements:
SELECTING IF STATE EQ "CA " SELECTING IF STATE EQ "CA+"
Using both SELECTING statements constitutes an "OR" condition, so all customers with "CA " or "CA+" in the STATE field would be reported.
If you merely requested
SELECTING IF STATE EQ "CA" (no trailing blank)
there would be no records selected for the report.