Database Reference
In-Depth Information
In the code example above, the IEssCube.calculate method has a void return type. In
other words, it does not have a return code, so how would you know if the CalcProd.csc
file has a syntax error? If there is a syntax error, the method will throw an EssException.
This is a very common pattern in Java and in the Essbase Java API.
Another common pattern in the Essbase Java API is the presence of method
overloads that have the same number and type of arguments, but are in a different
order. This is exactly the case with the overload that allows you to specify a Calc Script
to be executed on-the-fly, which also takes a string and a Boolean as arguments. In
this case, however, the string argument is the first argument in the list and repre-
sents the text of the Calc Script that will be sent to the server. The second argument
is a Boolean flag that indicates whether the method should merely perform a syntax
check on the script text. For this example, let us consider our previous code sample
where we updated some Essbase data. In that last example, we saw that the Colas
member was not calculated after the update, so this is a perfect example of a situation
where you may want to write a custom calculation to aggregate a slice of the database.
The Calc Script to aggregate a small slice of the database may appear as below:
FIX(BUDGET, "New York", Sales)
AGG(Product);
ENDFIX;
In most cases, you would want to build the script above in code. The most efficient way
to incrementally build a string in Java utilizes the StringBuilder class. The StringBuilder
stores characters in an array in memory. The StringBuilder.toString method returns the
contents of:
StringBuilder as a Java String object.
// create a stringbuilder
StringBuilder calc = new StringBuilder(1024);
// add the lines of the script
calc.append("FIX(BUDGET, \"New York\", Sales)\n");
calc.append("AGG(Product);\n");
calc.append("ENDFIX;");
// execute the calc
cube.calculate(calc.toString(), false);
If we retrieve the data once more, we will see that now the total for Colas is now cor-
rectly aggregated.
Budget
New York
Sales
Jan
Feb
Mar
Qtr1
Cola
100.0
100.0
100.0
300.0
Diet Cola 100.0
100.0
100.0
300.0
Colas
200.0
200.0
200.0
600.0
In this chapter, we have discussed how to connect to Essbase, get access to an indi-
vidual cube and then read and write data to it. There are a number of other things you
will need to do in order to create a complete application, and quite often those things
revolve around Essbase members. next, let us turn our attention to the different ways
that you can get member information via the Java API.
Search WWH ::




Custom Search