Oracle9i OLAP Services Developer's Guide to the Oracle OLAP API
Release 1 (9.0.1)

Part Number A88756-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

Performing Calculations, 2 of 7


Performing Numerical Operations

How do you perform numerical operations?

Using the OLAP API you perform basic numeric operations using NumberSource methods such as minus. There are separate versions of each of these methods that you can use to specify a literal double, float, int, or short value. There is also a version of each of these method that takes a NumberSource as an argument.

The OLAP API methods that you use to perform basic numeric operations include those outlined in the following table.

Method 

Description 

div(rhs)  

Divides the value of each element of the NumberSource by the specified value. 

intpart(

Identifies the integer portion of the value of each element of the NumberSource

minus(rhs) 

Subtracts the specified value from the value of each element of the NumberSource

negate() 

Negates the value of each of the elements of the NumberSource

plus(rhs) 

Adds the specified value to the value of each element of the NumberSource 

rem(rhs) 

Divides the value of each element of the NumberSource by the specified double value and determines the remainder for each operation. 

times (rhs

Multiplies the value of each element of the NumberSource by the specified value. 

Example: Subtracting the same value from all elements

Assume, as shown below. that there is a NumberSource named unit_Cost that has outputs of productsDim and timesDim and a type of Integer.

Output2 

Output1 

Element 

productsDim 

timesDim 

unit_Cost 

Boys 

1998 

4000 

Boys 

... 

... 

Boys 

31-DEC-01 

10 

... 

... 

... 

49780 

1998 

500 

49780 

... 

... 

49780 

31-DEC-01 

Now assume that you want to subtract 10% of the sales from each element to find the adjusted income for each product. To do this you use the following code.

NumberSource percentAdjustment = unit_Cost.minus(unit_Cost.times(.10));

The new NumberSource, named percentAdjustment, has the following structure and values.

Output2 

Output1 

Element 

productsDim 

timesDim 

unit_Cost 

Boys 

1998 

3600 

Boys 

... 

... 

Boys 

31-DEC-01 

... 

... 

... 

49780 

1998 

450 

49780 

... 

... 

49780 

31-DEC-01 

Example: Subtracting the values of one NumberSource from another

Assume that you have the NumberSource named unitCost described in the previous example and that you also have the NumberSource named unitManufacturingCost shown below.

Output 

Output 

Element 

productsDim 

timesDim 

Integer 

Boys 

1998 

600 

Boys 

... 

... 

Boys 

31-DEC-01 

... 

... 

... 

49780 

1998 

250 

49780 

... 

... 

49780 

31-DEC-01 

Now assume that you want to calculate the non-manufacturing for each product. To do this you need to subtract the manufacturing costs from the unit costs using the code shown below.

NumberSource nonManufacturingCost = unitCost.minus(unitManufacturingCost);

The new NumberSource has the structure and values shown below.

Output 

Output 

Element 

productsDim 

timesDim 

Integer 

Boys 

1998 

3400 

Boys 

... 

... 

Boys 

31-DEC-01 

... 

... 

... 

49780 

1998 

250 

49780 

... 

... 

49780 

31-DEC-01 

For a more complete explanation of these methods, see Oracle OLAP API Reference.


Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 1996-2001, 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