Database Reference
In-Depth Information
In this recipe, we loop through all the databases on a server and check for locks on the
types of files that most commonly need to have locks on them cleared.
import com.essbase.api.session.IEssbase
essHome = IEssbase.Home.create(IEssbase.JAPI_VERSION)
essSvr = essHome.signOn('user', 'pass', false, null, 'embedded',
'ess_server')
essSvr.applications.all.each { essApp ->
essApp.cubes.all.each { essCube ->
com.essbase.api.datasource.IEssOlapFileObject.with { //
'with' saves typing!
[TYPE_OUTLINE, TYPE_CALCSCRIPT, TYPE_PARTITION, TYPE_
REPORT, TYPE_RULES]
}.each { fileType ->
essCube.getOlapFileObjects(fileType).all.each {
fileObj ->
if (fileObj.isLocked()) {
essCube.unlockOlapFileObject(fileType,
fileObj.name)
println "Unlocked ${essApp.
name}.${essCube.name}.${fileObj.name}!"
}
}
}
essCube.clearActive()
}
}
essSvr.disconnect(); essHome.signOff();
9.5.10 Executing a MaxL Command
many developers are familiar with a battery of maxL commands and may be thinking as
they read these recipes about maxL commands that do the same things. We can leverage
that knowledge to run maxL commands from inside our scripts, going back and forth
between full JAPI programming and maxL as it suits us. This recipe demonstrates two
methods of doing this. The first is applicable only to the latest versions of Essbase.
import com.essbase.api.session.IEssbase
essHome = IEssbase.Home.create(IEssbase.JAPI_VERSION)
essSvr = essHome.signOn('user', 'pass', false, null, 'embedded',
'ess_server')
essMaxL = essSvr.openMaxLSession("default") // 11.1.2.x feature
essMaxL.execute("alter system load application Sample;")
essMaxL.execute("alter application Sample load database Basic;")
essMaxL.execute("alter database Sample.Basic reset data;")
essMaxL.execute("""import database Sample.Basic data from data_file
'Path\\To\\Calcdat.txt' on error abort;""")
messages = essMaxL.messages.each {
println it //print the results of each command
}
essMaxL.close(); essSvr.disconnect(); essHome.signOff();
Search WWH ::




Custom Search