Oracle® OLAP DML Reference 10g Release 1 (10.1) Part Number B10339-02 |
|
|
View PDF |
The LIMIT command sets the current status list of a dimension and its dimension surrogates, or assigns values to a valueset. You use LIMIT to restrict the data values you are working on by temporarily limiting the range of the dimensions of the data. Using LIMIT, you create a current status list for a dimension. The current status list of a dimension is an ordered list of currently accessible values for the dimension. Values that are in the current status list of a dimension are said to be "in status." For more information on dimension status and its importance when working with analytic workspace data, see "Working with Subsets of Data".
Syntax
LIMIT {dimension|valueset} [concat-component] limit-type [limit-clause] [IFNONE label]
where:
limit-type is one of the following keywords that specify how Oracle OLAP should modify the current status list:
limit-clause specifies the values to use for the limit. There are several types of limit-clause:
{inclusive_val_args....| exclusive_val_args}
LEVELREL level-relation [valueset2]
related-dimension [related-dimension-valuelist]
[family-keyword] USING parent-relation [inclusive_val_args]
NOCONVERT [{unrelated-dimension|numeric-valueset}]
POSLIST poslist-exp
Arguments
The name of the dimension or dimension surrogate for which you are setting status.
The name of the valueset for which you are assigning values.
Specifies the name of the component of the concat dimension whose values are used to determine the limit. When you specify a value for concat-component, the limit sets the status of the specified concat dimension using the values of dimension which is a component of the concat dimension. This limit-clause applies only when dimension is a concat dimension. The status of a concat dimension and of its component dimensions are not shared. Changing the status of a component dimension after you have used that dimension as the limit-clause in setting the status of a concat dimension does not change the status of the concat dimension.
Replaces the status of a dimension or valueset with the values specified by the limit-clause arguments. The TO keyword selects values from the default status of a dimension in the same order as they appear in the LIMIT command or in the order implied by the valuelist argument. When you use arguments that imply ordering, the ordering of the values is based on their positions in the default status.
Expands the status of a dimension or valueset by adding the values specified by the limit-clause arguments that are not already in status. The ADD keywords selects values from the default status of a dimension in the same order as they appear in the LIMIT command or in the order implied by the valuelist argument. When you use arguments that imply ordering, the ordering of the values is based on their positions in the default status. ADD adds unique dimension values in the specified order at the end of the current status list or valueset list.
Expands the status of a dimension or valueset by inserting the values specified by the limit-clause arguments in a specified position in the current status. The INSERT keyword selects values from the default status of a dimension in the same order as they appear in the LIMIT command or in the order implied by the valuelist argument.
When you use arguments that imply ordering (for example,value1
TO
value2
), the ordering of the values is based on their positions in the default status. INSERT adds values to a specified position in the current status. When an added value is already in status, it is removed from its position in the current status and added in the order in which it appears in the valuelist, preserving the order of the added values.
Inserts the new values before the first value in status.
Inserts new values after the last value in status.
Specifies whether new values Oracle OLAP inserts new values before or after position in the current status.
A dimension value in the current status, a character expression whose value is a dimension value in the current status, or an integer expression whose value represents the position of a dimension value in the default status.
Reduces the status of a dimension or valueset by keeping only the values specified by the limit-clause arguments. Oracle OLAP performs the selection based on the current dimension status. KEEP preserves the current order of values among the values that remain in the status.
Reduces the status of a dimension or a valueset by removing the values specified by the limit-clause arguments. Oracle OLAP performs the selection based on the current dimension status. KEEP preserves the current order of values among the values that remain in the status.
Replaces the status of a dimension or valueset with the values that are not specified by the limit-clause arguments. When you do not specify any arguments after COMPLEMENT, status is replaced by all values not now in status. Oracle OLAP performs the selection based on the current dimension status. COMPLEMENT leaves dimension values that remain in their default order. (Abbreviated COMP)
Sorts the values of a dimension or valueset according to the limit-clause arguments. LIMIT creates a temporary list of values based on the limit-clause arguments, and uses this list to sort the current status list. Any values not present in the temporary list are moved to the end of the current status list.
Specifies the values to use for the limit. There are several types of limit clauses. Because the complete syntax for each type of limit clause is complex, subsequent entries discuss the LIMIT command with each type of clause:
(For use only within an OLAP DML program) Specifies that program execution should branch to label when the requested status has null status or is based on a related dimension that turns out to have null status (that is, to have no values). In either case, the null status is not put into effect when program execution branches. Instead, the original status, before the LIMIT command was executed, is retained. This is true even when OKNULLSTATUS is YES
. Within an OLAP DML program, you cannot use both IFNONE and NULL in the same command.
The name of a label elsewhere in the program constructed following the "Guidelines for Constructing a Label". Execution of the program branches to the line directly following the specified label.
Note that label, as specified in IFNONE, must not be followed by a colon. However, the actual label elsewhere in the program must end with a colon.
Notes
To specify a value of a nonunique concat dimension, use the following syntax.
<base-dimension: value>.
When you first attach an analytic workspace, the current status list of each dimension consists of all of the values of the dimension that have read permission, in the order in which the values are stored. This list of values is called the default status list for the dimension.
LIMIT selects only unique values of a dimension. When a value appears more than once in a LIMIT command, it is placed in status in the order of its first appearance. For example, the following lines.
LIMIT time TO 'Jan97', 'Feb97', 'Jan97' STATUS time
produce this output.
The current status of TIME is: JAN97, FEB97
Oracle OLAP does not signal an error when you try to set the status of a dimension or valueset that has no values, unless you explicitly list values that do not exist. For example, assume that you have not added any values to a newly defined dimension WEEK. In this case, the statement LIMIT week TO FIRST 10
does not cause an error. However, LIMIT week TO 'Pete'
causes an error because Pete
is not a value. Similarly, LIMIT week TO 20
causes an error because week
does not have a value at position 20
.
Oracle OLAP allows the status of a dimension or valueset to be set to null (empty status) only when you have explicitly specified that you want null status to be permitted. You can give this permission in either of two ways:
Set the OKNULLSTATUS option to YES
. This specification indicates that null status should be allowed whenever it occurs (except when the IFNONE argument is present in a LIMIT command).
Use the NULL keyword in a LIMIT command to set the status of a particular dimension or valueset to null. You can do this by specifying TO NULL or KEEP NULL. This specification indicates that null status should be allowed for this LIMIT command only.
When you have not used either of these two methods to give permission for null status and you execute a LIMIT command that would result in null status, Oracle OLAP does not change the status to null when it executes the statement. Instead, Oracle OLAP leaves the status as it was before the statement was issued and either signals an error (when IFNONE is not present) or branches to the IFNONE label (when IFNONE is present).
An IFNONE argument indicates that you do not want program execution to take its normal course when a dimension's status were to be set to null. Therefore, when IFNONE is present, Oracle OLAP branches to the IFNONE label and does not set the status to null, even when OKNULLSTATUS is YES
. When the NULL keyword is present together with IFNONE, Oracle OLAP signals the inconsistency with an error.
IFNONE requires the use of unstructured programming techniques. Oracle OLAP now provides alternative structured techniques, so the use of IFNONE is discouraged. IFNONE has been retained for compatibility with previous versions of Oracle OLAP.
To limit a conjoint dimension to a value list, you can use the following constructions:
Specify the actual values, surrounding each combination with angle brackets
LIMIT proddist TO '<Tents, Boston>' - '<Footwear, Denver>'
Use a variable name for the values, surrounding the combination with angle brackets.
prodname = 'Canoes' distname = 'Seattle' LIMIT proddist To <prodname, distname>
Create a multiline list, where each line is a combination surrounded by angle brackets.
namelist = '<Tents Boston>\n<Footwear, - Denver>\n <Canoes, Seattle>' LIMIT proddist TO namelist
Use the implicit relation between a conjoint dimension and its base dimension to limit the conjoint dimension. For example, use the following statement to limit PRODDIST to all conjoint values having "Canoes" as one of its base values.
LIMIT proddist TO product 'Canoes'
Note: You can use logical position numbers for base dimension values in a conjoint dimension. "Using INSTAT When the Dimension is a Conjoint Dimension" illustrates using logical position numbers |
For an example of how you can limit a conjoint dimension that has a concat base dimension, see Example 16-13, "Limiting a Conjoint Dimension with a Concat Base Dimension".
You can define a concat dimension using simple dimensions, conjoint dimensions, and other concat dimensions as the base dimensions of the concat. The syntax for limiting a concat dimension to one of its values is the following.
LIMIT concatdim TO <base-dim: value>
For example, the concat dimension reg.dist.ccdim
has the simple dimensions region
and district
as its base dimensions. The following statement sets the status of reg.dist.ccdim
to two of its values, region: East
and district: Atlanta
.
LIMIT reg.dist.ccdim TO <region: 'East'> <district: 'Atlanta'>
For other methods of setting the status of a concat dimension, see Example 16-4, "Limiting a Concat Dimension".
As an alternative to branching to an IFNONE
label, you can also handle null status for a dimension with the OKNULLSTATUS option. When you set OKNULLSTATUS to YES
, then you are allowed to set the status of a dimension to null. You can then check for null status and execute appropriate commands with an IF...THEN...ELSE command, or you can handle null status as one of the cases in a SWITCH command.
OKNULLSTATUS = YES LIMIT month TO sales GT salesnum IF STATLEN(month) LT 1 THEN GOTO showerr
Examples
Example 16-2 Adding and Removing Values
These lines add values to the status for the month
dimension.
LIMIT month TO 'Jan96' TO 'Jun96' LIMIT month ADD 'Jul96' 'Sep96'
Issuing a STATUS month
statement produces this output.
The current status of MONTH is: Jan96 TO Jul96, Sep96
This line removes values from the status for the month
dimension.
LIMIT month REMOVE 'Jan96' TO 'Mar96'
Now, issuing a STATUS month
statement produces this output
The current status of MONTH is: Apr96 TO Jul96, Sep96
Example 16-3 Limiting with a Dimension Surrogate
A dimension and any dimension surrogates for it share the same status.
For example, assume that there is a NUMBER dimension named store_id
that has the values 25
, 410
, 150
, 205
, 310
, and 10
. It also uses storepos
, an INTEGER dimension surrogate for store_id
. The dimension surrogate storepos
has the values 1
, 2
, 3
, 4
, 5
, and 6
. A TEXT dimension surrogate for store_id
is storename
. It has the text values Raoul's - Boston
, Poldy's Potpourri
, Molly's Emporium
, Raoul's - Atlanta
, Kinch's Kitchen Supplies
, and Raoul's - Chicago
. The following statements are equivalent.
LIMIT store_id TO 25 410 150 LIMIT store_id TO storepos 1 2 3 LIMIT storepos TO 1 TO 3 LIMIT storepos TO first 3 LIMIT storename TO first 3 LIMIT storename TO 'Raoul\'s - Boston' TO 'Molly\'s Emporium' LIMIT store_id TO storename storepos 1 2 3 LIMIT storename TO store_id 25 TO 150
The following statements set the status of the NUMBER type store_id
dimension by limiting storename
, which is a TEXT dimension surrogate for store_id
, and report the values of store_id
.
LIMIT storename TO 'Raoul\'s Sweets' TO 'Henry\'s Flowers' REPORT store_id
The preceding statement produces the following output.
STORE_ID -------------- 10 20 30
Example 16-4 Limiting a Concat Dimension
In the following examples, the concat dimension reg.dist.ccdim
has the simple dimensions region
and district
as its base dimensions. A concat dimension has an implicit relation to each of its component dimensions.
The following statement sets the status of the concat dimension using the related dimension syntax and specifying the positions of the component (related) dimension.
LIMIT reg.dist.ccdim TO district 1, 4, 5
Issuing a STATUS reg.dist.ccdim
statement produces the following output.
The current status of REG.DIST.CCDIM is: <DISTRICT: BOSTON>, <DISTRICT: DALLAS>, <DISTRICT: DENVER>
The following statement limits the concat dimension directly to the values specified by positions of the concat dimension.
LIMIT reg.dist.ccdim TO 1, 4, 5
Issuing a STATUS reg.dist.ccdim
statement produces the following output.
The current status of REG.DIST.CCDIM is: <REGION: EAST>, <DISTRICT: BOSTON>, <DISTRICT: ATLANTA>
The following statements set the status of district
and then limit reg.dist.ccdim
to the status of district
.
LIMIT district TO LAST 3 LIMIT reg.dist.ccdim TO district
Issuing a REPORT reg.dist.ccdim
statement produces the following output.
REG.DIST.CCDIM ---------------------- <district: Dallas> <district: Denver> <district: Seattle>
In the following statement, the limit-clause argument is a list of values of the concat dimension.
LIMIT reg.dist.ccdim TO <region: 'East'> <district: 'Boston'> <district: 'Atlanta'>
The following statements define a valueset for reg.dist.ccdim
, store the current status of the concat dimension in the valueset, reset the status of the concat to ALL
, and then limit the concat to the valueset and report the values of the concat in status.
DEFINE regdist.vset VALUESET reg.dist.ccdim LIMIT regdist.vset TO reg.dist.ccdim LIMIT reg.dist.ccdim TO ALL LIMIT reg.dist.ccdim TO regdist.vset RPR W 22 reg.dist.ccdim
The preceding statements produce the following result.
REG.DIST.CCDIM ---------------------- <region: East> <district: Boston> <district: Atlanta>
You can also limit a concat dimension using a valueset of one of its component dimensions.
When the component dimensions contain identical values, you can limit the concat dimension to those values by using a Boolean expression. When the district
and region
dimensions both have New
York
as a value, then the following statement limits the reg.dist.ccdim
to those values.
LIMIT reg.dist.ccdim TO BASEVAL(reg.dist.ccdim) EQ 'New York'
In the following example, the concat dimension geog
has the simple dimension region
and the conjoint dimension cityandstate
as its base dimensions. The following statement sets the status of the concat dimension by limiting the conjoint base dimension.
LIMIT geog TO cityandstate <'Princeton' 'New Jersey'> - <'Patterson' 'New Jersey'>
Issuing a STATUS geog
statement produces the following output.
The current status of GEOG is: <CITYANDSTATE: <PRINCETON, NEW JERSEY>, <CITYANDSTATE: <PATTERSON, NEW JERSEY>>
The following statements sets the status of the concat dimension by limiting the conjoint base dimension by specifying a value of a base dimension of the conjoint dimension.
LIMIT geog TO cityandstate city 'Princeton' RPR W 30 geog
The preceding statement produces the following output.
GEOG ------------------------------ <cityandstate: <Princeton, New Jersey>> <cityandstate: <Princeton, Indiana>>
Example 16-5 Limiting with a Worksheet
This example shows how to limit a dimension to the values that are contained in a column of a worksheet. Here the dimension month
is limited to the values that are contained in the first column of the worksheet workitem
. The following statements produce a workitem
report, which is shown following the statements.
LIMIT month TO ALL LIMIT wkscol TO 1 LIMIT wksrow TO workitem NE NA REPORT workitem -WORKITEM- --WKSCOL-- WKSROW 1 -------------- ---------- 1 Jan96 2 Feb96 3 Mar96 4 Apr96 5 May96 6 Jun96 7 Jul96 8 Aug96 9 Sep96 10 Oct96 11 Nov96 12 Dec96
The following statement limits the month
dimension to the values that are listed in the first column of workitem
.
LIMIT month TO CHARLIST(workitem)
Issuing a STATUS month
statement produces the following output.
The current status of MONTH is: Jan96 TO Dec96
Example 16-6 Using Ampersand Substitution with LIMIT
Assume that you want specify exactly two products for a program named product.rpt
. In this cae, you could declare two dimension-value arguments to handle them. But when you want to be able to specify any number of products using LIMIT commands, then you can use a single argument with ampersand substitution.
Suppose you use the following commands in your program.
ARGUMENT natext TEXT ARGUMENT widthamt INTEGER ARGUMENT rptprod TEXT ... LIMIT product TO &rptprod
You can run the program and specify that you want the first three products in the report.
CALL product.rpt ('Missing' 8 'first 3')
The single quotation marks are necessary to indicate that "first 3" should be taken as a single argument, rather than two separate arguments separated by a space. The ampersand causes the LIMIT command to interpret 'first 3'
as a keyword expression rather than as a dimension value.
Example 16-7 Branching on Null Status
Your program might try to set or refine the status of the product
dimension to include only the products for which unit sales are greater than 500. When no products have unit sales of more than 500, then you can use the IFNONE
keyword to specify that execution branch to the novals
label.
LIMIT product KEEP units GT 500 IFNONE novals
In the commands following the novals
label, you can handle the special situation in which no products have units sales greater than 500.
A LIMIT command with a using values limit clause assigns valules to a valueset or sets the current status list of a dimension or dimension surrogates to:
Specified value or values. The values can be any of the following:
Dimension values, expressed as literal values separated by commas, or as a multiline text expression, each line of which is a value of the dimension.
Ranges of dimension values, expressed as value1 TO value2.
Integer values that represent the logical positions of dimension values, expressed as comma-delimited integers.
Ranges of INTEGER values that represent the logical positions of dimension values, expressed as value1 TO value2.
Valuesets.
Values for which a Boolean expression is TRUE
.
The top or bottom performers of a dimension based on a criterion
The top or bottom performers of a dimension, by percentage, based on a criterion represented as an expression
Syntax
LIMIT {dimension|valueset} [concat-component] limit-type -
{inclusive_val_args....| exclusive_val_args} [IFNONE label]
where:
inclusive_val_args is one or more of the following constructs:
intvaluelist
text-expression
value1 TO value2
valuelist
valueset
exclusive_val_args is one of the following constructs:
ALL
boolean-expression
{BOTTOM|TOP} n BASEDON expression
{BOTTOM|TOP} n-percent PERCENTOF expression
{FIRST|LAST|NTH} n
LONGLIST
NULL
Arguments
The name of the dimension or dimension surrogate for which you are setting status.
The name of the valueset for which you are assigning values.
The name of the component of the concat dimension whose values are used to determine the limit. (See the main entry for LIMIT command for complete description of this argument.)
A keyword that specifies how Oracle OLAP should modify the current status list. (See the main entry for LIMIT command for a list and descriptions of these keywords.)
A list of one or more integers, or the name of a single-cell variable that holds a numeric value. Separate the values with commas (,
). Numeric values with decimal places (SHORTDECIMAL or DECIMAL values) are automatically truncated to integers before being used as dimension values. An integer specifies a dimension value by its logical position in the full set of dimension values. You cannot specify a NUMBER dimension value by an integer position. When the values of the NUMBER dimension are integers, then you can set the status of the dimension by specifying dimension values, as in intvalue1, intvalue2 and so on.
A multiline text expression, each line of which is a value of dimension.
Specifies a range of dimension values where value1 and value2 can be either dimension values or integers. Such a range can be increasing (for example, 1 to 10) or decreasing (for example, 10 to 1). The status of the dimension or valueset is assigned accordingly. You cannot specify the values of a NUMBER dimension by using INTEGER positions. Instead, you can define an INTEGER dimension surrogate for the NUMBER dimension and limit the dimension by the positions of the surrogate.
A list of one or more values of dimension. A dimension value can be specified as a text expression whose value is a valid dimension value. For a NUMBER dimension, dimension values are numbers. For dimensions with a type of DAY, WEEK, MONTH, QUARTER, or YEAR, dimension values can also be specified as DATE expressions.
An analytic workspace valueset object that is a saved list that holds the values for the dimension whose status is being set. You cannot define a valueset for a dimension surrogate, therefore you cannot specify a valueset when setting the status of a dimension surrogate. However, when you limit a dimension with a valueset, then you automatically limit to the same set any dimension surrogates of that dimension.
Specifies that all dimension values in the default status are to be included in the status. The default status is made up of all dimension values for which read permission is granted, in the same order as when the dimension was last maintained. When you start up an analytic workspace, the status for each dimension in your analytic workspace is the default status. Changing the read permission for a dimension with PERMIT or PERMITRESET commands changes the default status for the dimension.
An expression whose TRUE values are used by Oracle OLAP when limiting the dimension or status. The boolean-expression must be dimensioned by the dimension whose status is being set. For a dimension surrogate, the Boolean expression is evaluated over the dimension for which it is a surrogate. The data types of the expressions you are comparing in the Boolean expression must be similar. See the CONVERT function for information on converting data types. To correctly use LIMIT with a Boolean expression you need to understand how it works with a Boolean expression that has with more than one dimension, see "How LIMIT handles Boolean expressions with more than one dimension" for details.
Specifies that the status of a dimension or valueset is set based on a criterion, where n is the number of values to select and expression is the criterion on which to base the selection. All dimensions of expression other than the one whose status is being set must be limited to a single value. TOP results in the status sorted in descending order, BOTTOM results in the status sorted in ascending order. You cannot use a composite after the BASEDON keyword. When you attempt to do so, an error message will be displayed.
Specifies that the status of a dimension or valueset is set by finding the top or bottom performers based on a criterion represented as an expression. This construction sorts values and adds them to the status that is based on their contribution, by percentage, to an expression.
For example, the following statement sorts products in descending order by each product's contribution to TOTAL(sales)
and then add values to the status, starting from the top, until the cumulative total of sales
by product
reaches or exceeds 30 percent of all sales.
LIMIT product TO TOP 30 PERCENTOF TOTAL(sales, product)
Important: Do not use a criterion expression that causes a side effect or changes its own value. |
Specifies the first n, last n or nth values in the dimension's full set of values when used with TO, ADD, COMPLEMENT, or INSERT. When used with KEEP or REMOVE, specifies the first n, last n or nth values in the current status.
Important: It can happen that the last item in status, based on a PERCENTOF criterion, is one of a number of dimension values having the same associated criterion value. In this case, LIMIT includes all dimension values with that criterion value in the resulting status, even when that causes the total of the criterion value to far exceed the specified percentage. |
Indicates that there can be up to 2,000 arguments in the LIMIT command. When there are less than 300 arguments, LONGLIST is not needed.
Indicates an empty dimension or valueset list. Using this keyword with the TO or KEEP arguments removes all values from the current status, leaving an empty dimension or valueset list, even when OKNULLSTATUS is NO
. You cannot use IFNONE and NULL in the same LIMIT command. ADD, INSERT, and REMOVE NULL leave status unchanged. COMPLEMENT NULL places all values in status.
Specifies that program execution should branch to label when the requested status has null status or is based on a related dimension that turns out to have null status (that is, to have no values). (See the main entry for LIMIT command for complete description of this phrase.)
Notes
Keep the following points in mind when specifying values in limit-clause:
You can embed quoted strings within a quoted string, which is necessary when there are special characters in a base dimension value of a composite or conjoint dimension, such as Joe's Deli
. See the Example 15-23, "Embedding Quoted Strings" for an example of embedded quoted strings.
When the dimension has the NTEXT data type and an argument that represents a dimension value has the TEXT data type, LIMIT converts the argument value to NTEXT. Similarly, when the dimension has the TEXT data type and an argument that represents a dimension value has the NTEXT data type, LIMIT converts the argument value to TEXT; however, in this case, the conversion can result in data loss when the NTEXT value cannot be represented in the database character set.
When you specify a value of a dimension with a type of DAY, WEEK, MONTH, QUARTER, or YEAR, the value can be in the format specified by the VNF (value name format) for the dimension (or in the default VNF for the type of dimension you are limiting when the dimension does not have a VNF) or in a valid input style for DATE values.
You only need to provide the date components that are relevant for the type of dimension you are limiting. For a DAY or WEEK dimension, you must supply the day, month, and year components. For a MONTH or QUARTER dimension, you only need to supply the month and year (for example, Jun95
or 0695
for June 1995). For a YEAR dimension, you only need to specify the year (for example, 95
for 1995). The valid input styles for dates are discussed in DATEORDER.
When you specify a DATE expression or a text value that represents a complete date, you can specify any date that falls within the time period that is represented by the desired dimension value. Oracle OLAP uses the DATEORDERR option to resolve any ambiguities.
In the following LIMIT command, the sales
variable is dimensioned by three dimensions: product
, district
, and month
.
LIMIT product TO sales GT 90000
The result of the previous LIMIT command is evident when the district
and month
dimensions are limited to a single value, as they are when you execute these statements.
LIMIT month TO 'Jan95' LIMIT district TO 'Boston' STATUS product
The STATUS command produces the following output.
The current status of PRODUCT is: Footwear
In this case, the resulting status is all of the products whose sales exceed $90,000 for the month of January 1995 in the Boston district, which is only Footwear.
Consider the following example in which the MONTH dimension is not limited to a single value.
LIMIT product TO ALL LIMIT month TO 'Jan95' 'Feb95' 'Mar95' LIMIT district TO 'Boston'
When you execute a REPORT sales
statement, you can see the BOSTON sales figures for three months.
DISTRICT: BOSTON -------------SALES-------------- -------------MONTH-------------- PRODUCT Jan95 Feb95 Mar95 -------------- ---------- ---------- ---------- Tents 32,153.52 32,536.30 43,062.75 Canoes 66,013.92 76,083.84 91,748.16 Racquets 52,420.86 56,837.88 58,838.04 Sportswear 53,194.70 58,913.40 62,797.80 Footwear 91,406.82 86,827.32 100,199.46
However, the following LIMIT and STATUS commands produce the output shown following them. Again, only Footwear is in the status for month
.
LIMIT product TO sales GT 90000 STATUS product The current status of PRODUCT is: Footwear
In this case, each product has three sales figures, one for each month. For each product, LIMIT evaluates the sales data for only the first month in status. A product is added to the status when its sales data exceeds $90,000 in that month.
When you would like all months evaluated for each product, you can use the EVERY, ANY, or NONE functions. For example, the following LIMIT command adds a product to the status when any of its months has a sales figure that exceeds $90,000.
LIMIT product TO ANY(sales GT 90000, product)
In this case a STATUS product
statement produces the following output.
The current status of product is: Canoes, Footwear
Every dimension with a type of DAY, WEEK, MONTH, QUARTER, or YEAR is related to all other dimensions of this type through an implicit relation. When you limit the values of one DAY, WEEK, MONTH, QUARTER, or YEAR dimension by specifying another DAY, WEEK, MONTH, QUARTER, or YEAR dimension as the related-dimension, Oracle OLAP uses the implicit relation by default. However, when an explicit relation is defined between the two of these types of dimensions, you can override the default by specifying the name of the explicit relation as the related-dimension. For example, you can issue the following statement.
LIMIT month TO quarter year
This statement temporarily limits quarter
to year
, then limits month
to quarter
, and finally, restores quarter
to its original status.
Examples
Example 16-8 Limiting with a Literal Value
This example shows how to limit the status of a dimension to one or more values (the value1, value2 construction of valuelist).
LIMIT month TO 'Jan96'
Example 16-9 Limiting with a Boolean Expression
You can limit a dimension or valueset according to the values of a Boolean expression. In this example, the values of the TOTALL function are broken out by product
and compared to a constant. The LIMIT command sets the status to all the products whose sales, totaled for all months and districts, are greater than 12 million.
LIMIT product TO TOTAL(sales product) GT 12000000
Example 16-10 Limiting with a Formula
When you use the same criterion frequently to limit a dimension, you can save the expression as a formula and use the name of the formula as the limit expression.
DEFINE criterion FORMULA TOTAL(sales product) GT 12000000 LIMIT product TO criterion
Example 16-11 Limiting with a Valueset
You can save a status list in a valueset and use those values later to limit the status. When it takes several LIMIT commands to produce the status list you want, the valueset keeps you from having to repeat those LIMIT commands each time you need the same list. The following statements limit district
to the districts in which sportswear sales exceeded $1,000,000 in 1996. The status is saved in the valueset sports.district
, and you can limit district
to the same list with one LIMIT command.
DEFINE sports.district VALUESET district LIMIT product TO 'Sportswear' LIMIT month TO year 'Yr96' LIMIT sports.district TO TOTAL(sales district) GT 1000000 LIMIT district TO sports.district
Issuing a STATUS district
statement produces this output.
The current status of DISTRICT is: ATLANTA TO DENVER
Example 16-12 Limiting with a Variable
Here the TOP and BASEDON keywords are used to limit the status of a dimension, using the values of a variable as a criterion. The status list is sorted in descending order according to the values of sales
.
LIMIT product TO 'Sportswear' LIMIT month TO 'Jul96' LIMIT district TO TOP 2 BASEDON sales
The following REPORT command
REPORT DOWN district sales
produces this output, which shows the results of the LIMIT commands.
PRODUCT: SPORTSWEAR --SALES--- --MONTH--- DISTRICT Jul96 -------------- ---------- Dallas 220,416.81 Atlanta 211,666.14
Example 16-13 Limiting a Conjoint Dimension with a Concat Base Dimension
In the following examples, prod.regdist
is a conjoint dimension that has the product
simple dimension and the reg.dist.ccdim
concat dimension as its base dimensions. The conjoint dimension prod.regdist
has the following values.
Tents <region: East> Tents <region: West> Canoes <region: East> Canoes <region: West> Tents <district: Boston> Tents <district: Atlanta> Tents <district: Denver> Canoes <district: Atlanta> Canoes <district: Seattle>
You can set the status of a conjoint that has a concat dimension as a base dimension by specifying the concat dimension, one of its component dimensions, and a value of the component dimension as the LIMIT limit-clause as in the following statement.
LIMIT prod.regdist TO reg.proddist.ccdim district 'Atlanta' RPR W 20 prod.regdist
The preceding statement produces the following output.
--------------PROD.REGDIST--------------- PRODUCT REG.DIST.CCDIM -------------------- -------------------- Tents <district: Atlanta> Canoes <district: Atlanta>
You can also set the status of the conjoint by specifying its values as in the following statement.
LIMIT prod.regdist TO <'Tents' '<region: East>'> <'Tents' '<district: Boston>'> RPR W 20 prod.regdist
The preceding statement produces the following output.
--------------PROD.REGDIST--------------- PRODUCT REG.DIST.CCDIM -------------------- -------------------- Tents <region: East> Tents <district: Boston>
A LIMIT command with that uses only dimension values that are at the same level as the current level of the hierarchical dimension or dimension surrogate when setting status or assigning values to a valueset.
Syntax
LIMIT {dimension|valueset} [concat-component] limit-type-
LEVELREL level-relation [valueset2] -
[IFNONE label]
Arguments
The name of the dimension or dimension surrogate for which you are setting status.
The name of the valueset for which you are assigning values.
The name of the component of the concat dimension whose values are used to determine the limit. (See the main entry for LIMIT command for complete description of this argument.)
A keyword that specifies how Oracle OLAP should modify the current status list. (See the main entry for LIMIT command for a list and descriptions of these keywords.)
Sets the status of a hierarchical dimension to all of the values of the hierarchical dimension that are at the same level as the current value of the dimension; or, that limits a hierarchical dimension to those values of the hierarchical dimension that are at the same level as the current value of the dimension and that are also in a specified valueset.
Specifies the name of a level relation for the hierarchical dimension you want to limit. A level relation is a relation between a hierarchical dimension and another dimension (sometimes called the level dimension) that has the names of the levels of the hierarchy as values. A level relation is dimensioned by the hierarchical dimension and has the values of the level dimension. For example, assume that there is hierarchical TEXT dimension named time
, a level dimension for time
named tlevel
S, and a level relation named time.tlevels
that is dimensioned by time
. Assume also that the time
dimension has a unique value for months and years and the tlevels
dimension has two values Month
and Year.
In this case, for each month value (for example, Feb 97
), the time.tlevels
relation has a value of Month
; and, for each year value (for example, 1997
), the time.tlevels
relation has a value of Year
.
Specifies the name of a valueset object is dimensioned by the level dimension for the hierarchical dimension that you want to limit. Assume that there are the objects described in the description of the level-relation parameter. Additionally, assume that you have defined a valueset named bestsalesyear
that is dimensioned by tlevels
and, for each value, contains only the values of time
that pertain to the year with the best sales year (for example, 1998
). In this case, for Month
, bestsalesyear
would have a list of all of the months in 1998 (that is, Jan98
through Dec98
and for Year
would have only one value (1998
).
Specifies that program execution should branch to label when the requested status has null status or is based on a related dimension that turns out to have null status (that is, to have no values). (See the main entry for LIMIT command for complete description of this phrase.)
Examples
Example 16-14 Limiting to a Single Time Period of a Hierarchical Time Dimension
Assume that you have defined a hierarchical text dimension named time
, a level dimension named timelevels
that has Month
and Year
as values, and a relation named timelevelsrel
that is dimensioned by time
and that has timelevels
as a related dimension (that is, for each value of the time
dimension, timelevelsre
contains a value of either Month
or Year
) When you wanted to limit the values of time
that are already in status to only those values that are at the same level as Jan99
, you can issue the following statement:
LIMIT time TO LEVELREL timelevelsrel
A LIMIT command with a related-dimension limit clause that uses the values of a different related dimension to assign values to a valueset or to set the status of one dimension or a dimension surrogate.
Syntax
LIMIT {dimension|valueset} [concat-component] limit-type-
related-dimension [related-dimension-valuelist] -
[IFNONE label]
Arguments
The name of the dimension or dimension surrogate for which you are setting status.
The name of the valueset for which you are assigning values.
The name of the component of the concat dimension whose values are used to determine the limit. (See the main entry for LIMIT command for complete description of this argument.)
A keyword that specifies how Oracle OLAP should modify the current status list. (See the main entry for LIMIT command for a list and descriptions of these keywords.)
Specifies the name of a relation or a dimension that is related to the dimension being limited. Using a relation name enables you to choose which relation is used when there is more than one. You can also specify as related-dimension a dimension surrogate for the dimension you are limiting or a dimension surrogate of the related dimension. For example, dimsurr
is a dimension surrogate of dim2
and dim2
is related to dim1
. The dimension surrogate dimsurr
has the values Dsv1
, Dsv2
, Dsv3
and Dsv4
. The following statement limits dim1
by specifying values of dimsurr
.
LIMIT dim1 TO dimsurr dsv1 dsv3
The values of the related dimension or a dimension surrogate for the related dimension or the dimension specified using the syntax shown in LIMIT command (using values). When this argument is present in a LIMIT command, status is obtained by selecting the values of the dimension being limited, which are related to the related-dimension values. When valuelist is omitted, the current status of related-dimension is used.
Specifies that program execution should branch to label when the requested status has null status or is based on a related dimension that turns out to have null status (that is, to have no values). (See the main entry for LIMIT command for complete description of this phrase.)
Notes
When you limit a dimension or valueset to a related dimension, the resulting status is determined in a two-step process:
The dimension values are arranged in the order of the values of the related dimension.
When there is more than one value of the dimension for any value of the related dimension, those values are arranged in the order of their default status.
You can suppress the sort that occurs when you limit a dimension or valueset to a related dimension by setting LIMIT.SORTREL to NO
. This can significantly improve performance when the dimension you are limiting is large.
Note: When LIMIT.SORTREL isNO , printed output of a dimension may not appear in logical order. |
Oracle OLAP expects values that are from the dimension being limited. When you specify a related dimension and there is more than one relation between the two dimensions, Oracle OLAP chooses the relation in which the related dimension is the dimension being limited. For example, you might have two relations between district
and region
, as follows.
DEFINE REGION.DISTRICT RELATION REGION <DISTRICT> LD The region each district belongs to DEFINE DISTRICT.REGION RELATION DISTRICT <REGION> LD The primary district in each region
When a workspace contains both of these relations, you can no longer simply specify the following statement in order to limit district
to one region.
LIMIT district TO region 'East'
In the preceding statement, Oracle OLAP will use the relation district.region
, which holds one district value for each region, because it holds district values. However, the relation region.district
, which holds region values, is the one that will produce the desired result. You must limit region
first and then limit district
, specifying that you want to use the first relation.
LIMIT region TO 'EAST' LIMIT district TO region.district
Examples
Example 16-15 Limiting with a Related Dimension
Here the status of a dimension is limited using a related dimension (rel-dim argument). This statement limits district
to Boston
and Atlanta
, which are in the East
region.
LIMIT district TO region 'East'
This statement limits product
to Sportswear
and Footwear
, which are in the division that appears last in the list of division
values.
LIMIT product TO division LAST 1
A LIMIT command that uses a parent relation in its limit clause to set the status of a hierarchical dimension or its dimension surrogate, or assigns vallues to a valueset, based on family relationships within the hierarchy.
Syntax
LIMIT {dimension|valueset} [concat-component] limit-type-
[family-keyword] USING parent-relation [inclusive_val_args] -
[IFNONE label]
where family-keyword has one of the following constructs:
PARENTS
CHILDREN
ANCESTORS
DESCENDANTS
HIERARCHY [INVERTED] [NOORIGIN] [SKIP n] [DEPTH n] [RUN textexp]]
Arguments
The name of the dimension or dimension surrogate for which you are setting status.
The name of the valueset for which you are assigning values.
The name of the component of the concat dimension whose values are used to determine the limit. (See the main entry for LIMIT command for complete description of this argument.)
A keyword that specifies how Oracle OLAP should modify the current status list. (See the main entry for LIMIT command for a list and descriptions of these keywords.)
Finds the parent of each value in valuelist. For a dimension, when there is no valuelist, finds the parent for each value in status. For a valueset, when there is no valuelist, it finds the parent of each value in the valueset. It uses the parent-relation to look up the parent.
Finds the children of each value in valuelist. For a dimension, when there is no valuelist, finds the children for each value in status. For a valueset, when there is no valuelist, it finds the children of each value in the valueset. It uses the parent-relation to look up the children.
Finds the ancestors (that is, parents, grandparents, and so on) of each value in valuelist. For a dimension, when there is no valuelist, it finds the ancestors of each value in status. For a valueset, when there is no valuelist, it finds the ancestors of each value in the valueset. In other words it finds "parents" for the values and the "parents of the parents" until there are no new parents.
Finds the descendants (that is, children, grandchildren, and so on) of each value in valuelist. For a dimension, when there is no valuelist, it finds descendants for each value in status. For a valueset, when there is no valuelist, it finds the descendants of each value in the valueset. In other words, it finds the children of the values and the children of the children until there are no new children.
Finds the descendants (that is, children, grandchildren, and so on) based on a particular parent-relation. The difference is the order of the values. DESCENDANTS groups the values by level (all children, then all grandchildren, and so on); HIERARCHY places each group of children next to its parent. HIERARCHY includes the original values (that is, those in status before the LIMIT command was executed) in status.
Indicates that children should be listed before their parents. By default, children are listed after their parents.
Excludes the original values from the status. The default is to include original values.
Skips n generations for each value in valuelist. For dimensions, when there is no valuelist, it skips n generations for each value in status. For a valueset, when there is no valuelist, it skips n generations for each value in the valueset. This keyword, in combination with DEPTH, is helpful when drilling down; see Example 16-17, "Drilling Down Using SKIP and DEPT ".
Includes n generations down from each value of valuelist. For dimensions, when there is no valuelist, it includes n generations for each value in status. For a valueset, when there is no valuelist, it includes n generations of each value in the valueset. The default depth value is 99. This keyword, in combination with SKIP, is helpful when drilling down on values.
Executes a statement, represented as a text expression, every time a group of children is constructed. For example, you can sort each group of children based on information stored in an Oracle OLAP variable. In the following statement, markets will be sorted in increasing order based on unit sales every time a group of children is constructed.
LIMIT market TO HIERARCHY RUN 'SORT market a unit.m' USING -
market.market
Note: In this example, when you use KEEP or REMOVE instead of TO with your LIMIT command, the SORT command would have no effect. |
Specifies the values to use when determining parent values.
Specifies the name of a child-parent self-relation for the dimension. For each dimension value, the relation holds another value of the dimension which is its parent dimension value (the one immediately above it in a given hierarchy). This parent relation can have more than one dimension.
Specifies the values to use when determining the parent values. You can specify any inclusive valuelist argument as described in the syntax of the inclusive_val_args argument for the valuelist clause for limit-clause, for a list of inclusive arguments. To limit a dimension surrogate, use the parent relation for the dimension for which it is a surrogate.
Specifies that program execution should branch to label when the requested status has null status or is based on a related dimension that turns out to have null status (that is, to have no values). (See the main entry for LIMIT command for complete description of this phrase.)
Examples
Example 16-16 A Simple Drill Down
This example drills down on districts from the region level of the market dimension. First, the market dimension, which has embedded totals at the district, region, and total U.S. level, is limited to the region level data. This is done using the relation mlv.market
, which is a relation between marke
t and market.level
.
Issuing a REPORT mlv.market
statement produces the following output, which shows the values of mlv.market
.
MARKET MLV.MARKET -------------- ---------- Totus Totus East Region Boston District Atlanta District Central Region Chicago District Dallas District West Region Denver District Seattle District
The following LIMIT command limits the values of MARKET
, and the STATUS command produces the values currently in status. The output of STATUS is shown following the statements.
LIMIT market TO mlv.market 'Region' STATUS market The current status of MARKET is: EAST, CENTRAL, WEST
To drill down on the district level data from the region level, you can use LIMIT with the CHILDREN keyword. The following example uses a parent-relation called market.market
to perform the drill down. For each value of the market
dimension, this relation contains the name of its parent.
DEFINE market.market RELATION market <market> LD Self-relation for the Market Dimension
A report of market.market
produces the following output.
MARKET MARKET.MARKET -------------- ------------- Totus NA East Totus Boston Central Atlanta East Central Totus Chicago Central Dallas Central West Totus Denver West Seattle West
You can limit market
to the children of the East
, Central
, and West
regions by using the CHILDREN keyword with LIMIT.
LIMIT market TO mlv.market 'Region' Limit market TO CHILDREN USING market.market
A report of market
produces the following output.
MARKET ------------- Boston Atlanta Chicago Dallas Denver Seattle
Example 16-17 Drilling Down Using SKIP and DEPT
Consider the following statement.
LIMIT market TO HIERARCHY DEPTH 2 SKIP 1 USING market.market 'Totus'
Oracle OLAP will look in the child-parent relation (market.market
) to find the children and the grandchildren (DEPTH 2
) of Totus
and it will discard the first generation (SKIP 1
). The resulting status follows.
Totus Boston Atlanta Chicago Dallas Denver Seattle
Note that Totus
is included in status. With HIERARCHY, the original values are included in status.
The LIMIT command sets the current status list of a dimension and its dimension surrogates, or assigns values to a valueset.
A LIMIT command with the NOCONVERT keyword sets the status of one dimension based on the numeric position of values in a different dimension.
Syntax
LIMIT {dimension|valueset} [concat-component] limit-type -
NOCONVERT [{unrelated-dimension|numeric-valueset}] -
[IFNONE label]
Arguments
The name of the dimension or dimension surrogate for which you are setting status.
The name of the valueset for which you are assigning values.
The name of the component of the concat dimension whose values are used to determine the limit. (See the main entry for LIMIT command for complete description of this argument.)
A keyword that specifies how Oracle OLAP should modify the current status list. (See the main entry for LIMIT command for a list and descriptions of these keywords.)
Sets the status of a dimension based on the numeric position of the specified values in the status list of an another dimension.
Specifies the name of a dimension not related to the dimension being limited. Using this argument specifies that the status of a dimension or valueset is set based on the numeric position of each value in status of the unrelated-dimension. This is particularly useful when the two dimensions are in different analytic workspaces (for example, when a one-to-one correspondence exists between the product dimension in two analytic workspaces)
Specifies the a numeric valueset. When you use this argument, NOCONVERT sets the status based on the numeric values in the valueset. The numeric values represent the positions of the values in the default status of the dimension.
(For use only within an OLAP DML program) Specifies that program execution should branch to label when the requested status has null status or is based on a related dimension that turns out to have null status (that is, to have no values). (See the main entry for LIMIT command for complete description of this phrase.)
The LIMIT command sets the current status list of a dimension and its dimension surrogates, or assigns values to a valueset.
A LIMIT command with the POSLIST keyword sets the status of a dimension based on the position of the values within that dimension.
Syntax
LIMIT {dimension|valueset} [concat-component] limit-type -
POSLIST poslist-exp [IFNONE label]
Arguments
The name of the dimension or dimension surrogate for which you are setting status.
The name of the valueset for which you are assigning values.
The name of the component of the concat dimension whose values are used to determine the limit. (See the main entry for LIMIT command for complete description of this argument.)
One of the standard keywords (documented in the main entry for LIMIT command) that specifies how Oracle OLAP should modify the current status list.
Sets the status of a dimension based on the position of a value within a dimension. poslist-textexp is a text expression, each line of which is a numeric value that evaluates to a numeric position of the dimension being limited.
Specifies that program execution should branch to label when the requested status has null status or is based on a related dimension that turns out to have null status (that is, to have no values). (See the main entry for LIMIT command for complete description of this phrase.)