Skip Headers

Oracle9i OLAP Developer's Guide to the OLAP API
Release 2 (9.2)

Part Number A95297-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to beginning of chapter Go to next page

Making Queries Using Source Methods, 3 of 8


Selecting Based on Output Values

If you want to create a Cursor on a Source object, it cannot have any inputs. Since any Source created from an MdmMeasure or an MdmAttribute has inputs, the need to specify values for inputs is so universal that the OLAP API has a special join method to support it

Specifying values for the inputs of a Source is called changing inputs to outputs. In this sense, moving a Source from the list of inputs returned by the getInputs method to the list of outputs returned by getOutputs is similar to moving a column out of the GROUP BY list in SQL.

Using the join Method to Change Inputs to Outputs

To specify values for the input of a Source, thereby changing an input to an output, use the following join method where the original Source is the Source object that has the input that you want to become an output and the joined Source is the input you want to change.

Source newSource = base.join (Source joined);

This is a shortcut for the following join method.

Source newSource = base.join (joined, emptySource, Source.COMPARISON_RULE_REMOVE, true);

Note that the comparison Source is the empty Source that has no values. Consequently, even though the COMPARISON_RULE_REMOVE constant is specified, no values are removed as a result of the comparison. Also, because the visible flag is set to true, the joined Source becomes an output of the new Source.

Additionally, since many of the methods of Source class and its subclasses are methods that implicitly call the join method, some of these methods also change inputs to outputs.

Effect of Input-Output Order on Source Structure

The structure of a Source is determined by the order in which you turn the inputs of the Source into outputs. For a Source that has outputs, the first output that was created is the fastest-varying output; the last output that was created is the slowest-varying output.

When you string two join methods together in a single statement, the first join (reading left to right) is processed first. Consequently, when creating a single statement containing several join methods, make sure that the input that you want to be the fastest-varying of the new Source is the joined Source in the first join in the statement.

Assume that you have a primary Source named unitCost that you created from a MdmMeasure object named mdmUnitCost. The Source named unitCost has inputs of timesDim and productsDim, and no outputs.The timesDim and productsDim Source objects do not have any inputs or outputs. The order in which you turn the inputs of unitCost into outputs determines the structure of a Source on which you can create a Cursor. Example 6-2 shows the results when you join first to timesDim. Example 6-3 shows the results when you join first to productsDim.

Changing Inputs to Outputs with timesDim as the First Output Created

Assume also that you issue the code shown in Example 6-2 to turn the inputs of the primary Source named unitCost into outputs.

Example 6-2 Changing Inputs to Outputs with timesDim as the First Output Created

Source newSource = unitCost.join(timesDim).join(productsDim);

This code strings two join methods together. Because unitCost.join(timesDim) is processed first, the output values for timesDim are the first output values specified. You can also say that timesDim is the first output defined for the new Source. After the first join is processed, the set of data represented by the resulting unnamed Source has the structure depicted below.

timesDim (output1) values of unitCost

1998

4,000

500

31-DEC-01

9

500

After the second join is processed, the set of data represented by newSource consists of the names and the values of both of its outputs (that is, timesDim and productsDim). Since timesDim was the first output for which values were specified, it is the fastest-varying output and the new Source has the structure depicted below.

productsDim (output2) timesDim (output1) values of unitCost

Boys

1998

4,000

Boys

31-DEC-01

10

49780

1998

500

49780

31-DEC-01

9

Changing Inputs to Outputs with productsDim as the First Output Created

Assume that you issue the code in Example 6-3 to turn the inputs of unitCost into outputs.

Example 6-3 Changing Inputs to Outputs with productsDim as the First Output Created

Source newSource = unitCost.join(productsDim).join(timesDim);

This code shown in Example 6-3 strings two join methods together. Because unitCost.join(productsDim) is processed first, productsDim is the first output defined for the new Source. Consequently, productsDim is the fastest-varying output and the new Source has the structure depicted below.

timesDim (output2) productsDim (output1) values of unitCost

1998

Boys

4,000

1998

49780

500

31-DEC-01

Boys

10

31-DEC-01

48780

9

Selecting Based on Output Values and Source Values: Example

Assume that you have three primary Source objects named productsDim, promotionsDim, channelsDim, and timesDim, that you got from MdmDimension objects and that you have a primary Source object named sales that you got from an MdmMeasure object. The productsDim, promotionsDim, channelsDim, and timesDim objects do not have any outputs. The sales object has productsDim, promotionsDim, channelsDim, and timesDim as inputs.

To create a new Source named bigSeller whose values are all of the products that sold more than $10,000,000 in 1996, you can issue the code shown in Example 6-4.

Example 6-4 Selecting Based on Output Values and Source Values

Source promotionSel = promotionsDim.selectValue("Promo total");
Source channelSel = channelsDim.selectValue("Channel total");
Source timeSel = timesDim.selectValue("1996");
Source bigSellers = productsDim.select(sales.gt(10000000)).
    join(promotionSel).join(timeSel).join(channelSel);

Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 2000, 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback