Database Reference
In-Depth Information
load from a relational repository if only Sample.Basic had one. The method calls we use
for loading are named beginDataLoad, but the way we use them, it really means “do”
the load. That means we do not need to call endDataLoad. The last two parameters of
each call are a Boolean to indicate whether to “abort on error” and an integer indicating
the load buffer id. We use 0 for the buffer id, which is always ignored for BSo (block
storage option) anyway, and enables us to load to ASo with no additional complexity.
It is possible to set up and use more complex load buffers manually, but we do not cover
that here.
import com.essbase.api.session.IEssbase
import com.essbase.api.datasource.IEssOlapFileObject
essHome = IEssbase.Home.create(IEssbase.JAPI_VERSION)
essSvr = essHome.signOn( 'user', 'pass', false, null, 'embedded',
'ess_server')
essCube = essSvr.getApplication('Sample').getCube('Basic')
essCube.clearAllData()
essCube.beginDataload('Data', IEssOlapFileObject.TYPE_RULES, 'Data.
xls', IEssOlapFileObject.TYPE_EXCEL, false, 0) // load from file
(Excel)
essCube.clearAllData()
essCube.beginDataload(null, IEssOlapFileObject.TYPE_RULES,
'Calcdat.txt', IEssOlapFileObject.TYPE_TEXT, false, 0) // load from
file (txt, no Load rule)
essCube.beginDataload('loadSql', IEssOlapFileObject.TYPE_RULES,
'sqlUser', 'sqlPass', false, 0) // load from relational
essCube.clearActive(); essSvr.disconnect(); essHome.signOff();
note that the cleanup code is consolidated on the last line to save space. normally, we
would not do that. We would use the cleanup code specified in this section's final recipe.
9.5.2 Running a Calc Script
The next step after loading data is often to calc the database, so we do that now. There are
three ways to execute a calc script in the IEssCube interface, and we demonstrate all of
them. The Chapter 8 (Deep Inside the Essbase Java API) contains detailed information
about these methods. note that we have to assume that Sample.Basic has a calc script
called rollup.csc.
import com.essbase.api.session.IEssbase
essHome = IEssbase.Home.create(IEssbase.JAPI_VERSION)
essSvr = essHome.signOn( 'user', 'pass', false, null, 'embedded',
'ess_server')
essCube = essSvr.getApplication('Sample').getCube('Basic')
essCube.calculate('CALC ALL;', false) // execute from a string
essCube.calculate(false, 'Rollup')
// execute from a file (leave
off '.csc')
essCube.calculate()
// execute the cube's default
calc
essCube.clearActive(); essSvr.disconnect(); essHome.signOff();
The “execute from a string” method suggests interesting possibilities: building scripts
on the fly, passing in parameters, or doing custom token substitution.
Search WWH ::




Custom Search