Database Reference
In-Depth Information
gv.setValue(2, 1, 100);
gv.setValue(2, 2, 100);
gv.setValue(2, 3, 100);
gv.setValue(2, 4, 100);
gv.setValue(3, 1, 100);
gv.setValue(3, 2, 100);
gv.setValue(3, 3, 100);
gv.setValue(3, 4, 100);
gv.setValue(4, 1, 100);
gv.setValue(4, 2, 100);
gv.setValue(4, 3, 100);
gv.setValue(4, 4, 100);
The creation of the operation is very straightforward, but locking the data cells
for update does give us some things to think about. When you lock data cells,
Essbase will place an exclusive write lock on data blocks where the data for the
given data cells are located. There are two ways to lock blocks in the Essbase Java
API. First, you can explicitly lock the blocks with the
IEssOpLock
operation, call
the
IEssOpUpdate
operation to write the data, and then unlock the blocks using
an
IEssOpUnlock
operation. Alternatively, you can use the
IEssOpUpdate.setPre-
viousLockRequired
method to direct the
IEssOpUpdate
operation to automatically
lock and unlock the cells. If the value passed to
setPreviousLockRequired
is false
or, in other words, if the cells have not been previously locked by an
IEssOpLock
operation, the
IEssOpUpdate
operation will automatically lock the cells before the
update and then unlock the cells after the update is complete. here is the code to
update the cells.
// create the operation
IEssOpUpdate update = cv.createIEssOpUpdate();
// mark it as locked
update.setPreviousLockRequired(false);
// perform the operation
cv.performOperation(update);
If you are working with an ASo database, the process is a little different.
ASo databases do not store their data in blocks, thus, there is no way to lock the blocks
for update. When writing to an ASo database, you must pass a Boolean value of
true
to
the
setPreviousLockRequired
method and not call
IEssOpLock
or
IEssOpUnlock
. In fact,
if you call the methods to lock or unlock data blocks on an ASo database, the Essbase
API will throw an
EssException
.
once the update is complete, we can retrieve the cells back from the database. In this
example, we are reusing the same retrieve object used previously. This is an important
point because it demonstrates that you can use the same
IEssOperation
object for mul-
tiple operations.
// now redo the retrieve
cv.performOperation(retrieve);