Oracle9i OLAP Developer's Guide to the OLAP API Release 2 (9.2) Part Number A95297-01 |
|
Introduction to Querying, 3 of 3
Making queries using the OLAP API is a process that involves creating a number of different Source
objects. This process is outlined below:
Source
objects that correspond to metadata objects as described in "Getting Source Objects From Metadata Objects". These Source
objects, sometimes called primary Source
objects, have a structure that is similar to the metadata objects from which they are created.Source
objects. The methods of the Source
class and its subclasses return new Source
objects sometimes called derived Source
objects. Continue your analysis by deriving additional Source
objects until you have the results you want to retrieve the data into your program. Derived Source
object and the methods that create them are introduced in "Creating New Source Objects Using Source Methods" and documented in detail in the OLAP API Javadoc. Task-oriented discussions of how to use Source
methods to make selections and perform typical analytic operations are provided in Chapter 6, "Making Queries Using Source Methods".
As part of the query process, you might also create simple nondimensional Source
object to use as operands when making selections and calculations and Source
objects that represent OLAP API data types. How to create these types of Source
objects is discussed in more detail in"Creating Simple Nondimensional Source Objects" and "Creating Source Objects that Represent OLAP API Data Types".
Source
object, create a Cursor
for it as described in Chapter 9, "Retrieving Query Results".To get a Source
object from a metadata object, take the following steps:
Source
object as described in Chapter 2.getSource
method to create a Source
object from the metadata object.A Source
that you create by using the calling the getSource
method on a MdmDimension
, an MdmHierarchy
, or an MdmLevel
does not have any inputs or outputs. It is a specification for a simple list of values.
In "Level MdmHierarchy for Calendar Year" , we created an MdmHierarchy
named mdmTimesDimCalHier
. To create a Source
named timesDimCalHier
from mdmTimesDimCalHier
, you use code shown in Example 5-1.
SourcetimesDimCalHier
=mdmTimesDimCalHier
.getSource;
The Source
named timesDimCalHier
consists of a simple non-indexed list of 1529 values: 4 values for year, 16 values for quarters, 48 values for months, and 1461 values for days.
timesDimCalHier values |
---|
1998 |
1998-Q1 |
1998-01 |
01-JAN-98 |
02-JAN-98 |
03-JAN-98 |
... |
1998-Q2 |
1998-04 |
01-APR-98 |
. . . |
1999 |
... |
A Source
that you create by calling the getSource
method on a MdmMeasure
or an MdmAttribute
is a specification for a data set that has one or more inputs. Each of these inputs is a primary Source
that was created from a MdmDimension
. Thus, the specification for a set of data represented by a Source
that you create from an MdmMeasure
or an MdmAttribute
is incomplete. Consequently, you cannot create a Cursor
on these Source
objects to retrieve their values into the application. To retrieve the values of a Source
created from a MdmMeasure
or an MdmAttribute
, you must derive a new Source
from it by specifying values for the values of the Source
objects that act as its dimensions as described in "Selecting Based on Output Values".
In "MdmMeasure with two MdmDimension objects" , we created an MdmMeasure
named mdmUnitCost
. To create a Source
named unitCost
from mdmUnitCost
, you use code shown in Example 5-2.
SourceunitCost
=mdmUnitCost
.getSource;
Since mdmUnitCost
has mdmProductsDim
and mdmTimesDim
as its MdmDimension
objects, unitCost
has two inputs (productsDim
and timesDim
). In order to retrieve one or more values of unitCost
, you must specify the values for its inputs (productsDim
and for timesDim
) that will uniquely identify the values of unitCost
. For information on specifying values for inputs, see "Selecting Based on Output Values".
Most OLAP queries derive new Source
objects from existing Source
objects using the methods in the Source
class.
Table 5-1 outlines the most important Source
methods in the OLAP API.
The OLAP API provides various other methods that you can use instead of the methods listed in Table 5-3, " The Major Source Methods". These methods include variations on the join
method, as well as methods such as appendValue
, at
, cumulativeInterval
, first
, ge
, interval
, selectValues
, and sortAscending
. All of these methods are documented in the OLAP API Javadoc. For task-oriented discussions on using these methods to analyze your data, see Chapter 6, "Making Queries Using Source Methods".
You create simple nondimensional Source
objects which are not based on metadata objects or other Source
objects that you can use as operands by using the createConstantSource
, createListSource
, and createRangeSource
methods on the DataProvider
class. These Source
objects are sometimes referred to as constant, list, and range Source
objects.
Assume that you have an object named myDataProvider
that represents the DataProvider
used by your application and that, for computational purposes, you want a Source
with a single value of 4. To create this Source
you issue the code shown in Example 5-3
NumberSource myConstantFour = myDataProvider.createConstantSource(4);
You can retrieve the objects that represent the OLAP API data types using methods on the FundamentalMetadataProvider
. Each of these methods returns a FundamentalMetadataObject
. The OLAP API data types and the methods you use to retrieve them are shown in Table 5-4.
To create a Source
object that represents an OLAP API data type, take the following steps:
FundamentalMetadataProvider
by using the getFundamentalMetadataProvider
method on the DataProvider
class.FundamentalMetadataObject
object that represents the OLAP API data type by using the appropriate method on the FundamentalMetadataProvider
class.Source
from the objects returned in Step 1 by using the FundamentalMetadataObject.getSource
method.Example 5-4 creates a Source
object called olapBooleanDataType
that represents the OLAP API Boolean data type. You can use olapBooleanDataType
to check to see if the OLAP API data type of any other Source
is Boolean.
FundamentalMetadataObject myFundamentalMetadataProvider = myDataProvider.getFundamentalMetadataProvider(); FundamentalMetadataObject olapBooleanFundObj = myFundamentalMetadataProvider.getBooleanType(); Source olapBooleanDataType = olapBooleanFundObj.getSource();
|
Copyright © 2000, 2002 Oracle Corporation. All Rights Reserved. |
|