In this section: |
How to: |
Reference: |
The WHERE phrase selects records from the data source to be included in a report. The data is evaluated according to the selection criteria before it is retrieved from the data source.
You can use as many WHERE phrases as necessary to define your selection criteria. For an illustration, see Using Multiple WHERE Phrases. For additional information, see Using Compound Expressions for Record Selection.
Note: Multiple selection tests on fields that reside on separate paths of a multi-path data source are processed as though connected by either AND or OR operators, based on the setting of a parameter called MULTIPATH. For details, see Controlling Record Selection in Multi-path Data Sources.
WHERE criteria [;]
where:
The WHERE phrase can include:
Note that files used with DECODE expressions can contain two columns, one for field values and one for numeric decode values.
You can build complex selection criteria by joining simple expressions with AND and OR logical operators and, optionally, adding parentheses to specify explicitly the order of evaluation. This is easier than trying to achieve the same effect with the IF phrase, which may require the use of a separate DEFINE command. For details, see Using Compound Expressions for Record Selection.
To show only the names and salaries of employees earning more than $20,000 a year, issue the following request:
TABLE FILE EMPLOYEE PRINT LAST_NAME AND FIRST_NAME AND CURR_SAL BY LAST_NAME NOPRINT WHERE CURR_SAL GT 20000 END
In this example, CURR_SAL is a selected field, and CURR_SAL GT 20000 is the selection criterion. Only those records with a current salary greater than $20,000 are retrieved. All other records are ignored.
The output is:
You can use as many WHERE phrases as necessary to define your selection criteria. This request uses multiple WHERE phrases so that only those employees in the MIS or Production departments with the last name of Cross or Banning are included in the report.
TABLE FILE EMPLOYEE PRINT EMP_ID LAST_NAME WHERE SALARY GT 20000 WHERE DEPARTMENT IS 'MIS' OR 'PRODUCTION' WHERE LAST_NAME IS 'CROSS' OR 'BANNING' END
The output is:
For related information, see Using Compound Expressions for Record Selection.
How to: |
Reference: |
When you report from a multi-path data source, a parent segment may have children down some paths, but not others. The MULTIPATH parameter allows you to control whether such a parent segment is omitted from the report output.
The MULTIPATH setting also affects the processing of selection tests on independent paths. If MULTIPATH is set to:
The MULTIPATH settings apply in all types of data sources and in all reporting environments (TABLE, TABLEF, MATCH, GRAPH, and requests with multiple display commands). MULTIPATH also works with alternate views, indexed views, filters, DBA, and joined structures.
To set MULTIPATH from the command level or in a stored procedure, use
SET MULTIPATH = {SIMPLE|COMPOUND}
To set MULTIPATH in a report request, use
ON TABLE SET MULTIPATH {SIMPLE|COMPOUND}
where:
Note: A unique segment is considered a part of its parent segment, and therefore does not invoke independent path processing.
The (FOC144) warning message is generated when a request screens data in a multi-path report:
(FOC144) WARNING. TESTING IN INDEPENDENT SETS OF DATA
For related information, see MULTIPATH and SET ALL Combinations and Rules for Determining If a Segment Is Required.
There is no limit to the number of segment instances (rows). However, no single segment instance can have more than 4K of active fields (referenced fields or fields needed for retrieving referenced fields). If this limit is exceeded, the SIMPLE setting is implemented and a message is returned.
This example uses the following segments from the EMPLOYEE data source:
The request that follows retrieves data from both paths with MULTIPATH = SIMPLE, and displays data if either criterion is met:
SET ALL = OFF SET MULTIPATH = SIMPLE TABLE FILE EMPLOYEE PRINT GROSS DATE_ATTEND COURSE_NAME BY LAST_NAME BY FIRST_NAME WHERE PAY_DATE EQ 820730 WHERE COURSE_CODE EQ '103' END
The following warning message is generated:
(FOC144) WARNING. TESTING IN INDEPENDENT SETS OF DATA
Although several employees have not taken any courses, they are included in the report output since they have instances on one of the two paths.
The output is:
If you run the same request with MULTIPATH = COMPOUND, the employees without instances for COURSE_NAME are omitted from the report output, and the warning message is not generated.
The output is:
LAST_NAME FIRST_NAME GROSS DATE_ATTEND COURSE_NAME --------- ---------- ----- ----------- ----------- JONES DIANE $1,540.00 82/05/26 BASIC REPORT PREP FOR PROG SMITH MARY $1,100.00 81/11/16 BASIC REPORT PREP FOR PROG
The ALL parameter affects independent path processing. The following table uses examples from the EMPLOYEE data source to explain the interaction of ALL and MULTIPATH.
Request |
MULTIPATH=SIMPLE |
MULTIPATH=COMPOUND |
---|---|---|
SET ALL = OFF PRINT EMP_ID PAY_DATE DATE_ATTEND |
Shows employees who have either SALINFO data or ATTNDSEG data. |
Shows employees who have both SALINFO and ATTNDSEG data. |
SET ALL = ON PRINT EMP_ID PAY_DATE DATE_ATTEND |
Shows employees who have SALINFO data or ATTNDSEG data or no child data at all. |
Same as SIMPLE. |
SET ALL = OFF PRINT EMP_ID PAY_DATE DATE_ATTEND WHERE PAY_DATE EQ 980115 |
Shows employees who have either SALINFO data for 980115 or any ATTNDSEG data. Produces (FOC144) message. |
Shows employees who have both SALINFO data for 980115 and ATTNDSEG data. |
SET ALL = ON PRINT EMP_ID PAY_DATE DATE_ATTEND WHERE PAY_DATE EQ 980115 |
Shows employees who have either SALINFO data for 980115 or any ATTNDSEG data. Produces (FOC144) message. |
Shows employees who have SALINFO data for 980115. Any DATE_ATTEND data is also shown. |
SET ALL = OFF PRINT ALL.EMP_ID DATE_ATTEND WHERE PAY_DATE EQ 980115 |
Shows employees who have either SALINFO data for 980115 or any ATTNDSEG data. Produces (FOC144) message. |
Shows employees who have SALINFO data for 980115. Any DATE_ATTEND data is also shown. |
SET ALL = ON or OFF PRINT EMP_ID PAY_DATE DATE_ATTEND WHERE PAY_DATE EQ 980115 AND COURSE_CODE EQ '103' |
Shows employees who have either SALINFO data for 980115 or COURSE 103. Note: SIMPLE treats AND in the WHERE clause as OR. Produces (FOC144) message. |
Shows employees who have both SALINFO data for 980115 and COURSE 103. |
Note: SET ALL = PASS is not supported with MULTIPATH = COMPOUND.
For related information about the ALL parameter, see Handling Records With Missing Field Values.
The segment rule is applied level by level, descending through the data source/view hierarchy. That is, a parent segment existence depends on the child segment existence, and the child segment depends on the grandchild existence, and so on, for the full data source tree.
The following rules are used to determine if a segment is required or optional:
When SET ALL = PASS, a segment with WHERE or IF criteria is optional.
Note: ALL = PASS is not supported for all data adapters and, if it is supported, it may behave slightly differently. Check your specific data adapter documentation for detailed information.
For related information about the ALL parameter, see Handling Records With Missing Field Values, and the Describing Data With TIBCO WebFOCUS® Language manual.