This is probably one of the lesser known feature of essbase. Quite up to the task as RDBMS
Understanding Essbase Triggers Definitions
The triggers feature enables efficient monitoring of data changes in a database. Triggers are licensed separately from Essbase. If data breaks rules that you specify in a trigger, Essbase logs relevant information in a file or, for some triggers, sends an email alert; for example, to notify the sales manager if, in the Western region, sales for a month fall below sales for the equivalent month in the previous year.
Monitoring Data Changes Using Triggers
The triggers feature provided by Essbase enables efficient monitoring of data changes in a database. If data breaks rules specified in a trigger, Essbase can log relevant information in a file or, for some triggers, can send an e-mail alert (to a user or system administrator); for example, to notify the sales manager if, in the Western region, sales for a month fall below sales for the equivalent month in the previous year.
There are two types of triggers: on-update triggers and after-update triggers. On-update triggers are activated during the update process, when the block containing the data referenced by the trigger is brought into memory. After-update triggers are activated after the update transaction is complete.
Note:
On-update triggers are supported only on block storage databases.
Trigger Examples
The following examples are based on the Sample Basic database.
Note:
You cannot define a trigger that requires data from hybrid analysis members. You cannot define an on-update trigger that requires data from Dynamic Calc members or from members from another partition.
Example 1, Tracking Sales for January
Example 1 tracks the Actual, Sales value for the following month, product, and region:
- January (Year dimension member Jan)
- Colas (Product dimension member 100)
- Eastern region (Market dimension member East)
When the member being calculated is Jan and when the Actual, Sales value of Colas for January exceeds 20, the example sends an e-mail to two e-mail accounts.
create trigger Sample.Basic.Trigger_Jan_20
where "(Jan,Sales,[100],East,Actual)"
when Jan > 20 and is(Year.currentmember,Jan) then
mail ([Docs.Company.com],[trgsales@company.com],
[inventory@company.com],
[Mail sent by trigger_Jan_20])
end;
Example 2, Tracking Sales for Quarter 1
Example 2 tracks the Actual, Sales value for the following months, product, and region:
- January, February, and March (the children of Year dimension member Qtr1)
- Colas (Product dimension member 100)
- Eastern region (Market dimension member East)
When the member being calculated is Jan, Feb, or Mar and when the Actual, Sales value of Colas for the month January, February, or March exceeds 20, the example logs an entry in the file Trigger_Jan_Sales_20, Trigger_Feb_Sales_20, or Trigger_Mar_Sales_20. On subsequent trigger activations, both old and new log values are retained in the log files.
create or replace trigger Sample.Basic.Trigger_Qtr1_Sales
log_value on
Where "(crossjoin(Qtr1.children, {(Measures.Sales, [100],
East, Scenario.Actual)}))"
When Year.Jan > 20 and is(Year.currentmember, Jan) then
spool Trigger_Jan_Sales_20
When Year.Feb > 20 and is(Year.currentmember, Feb) then
spool Trigger_Feb_Sales_20
When Year.Mar > 20 and is(Year.currentmember, Mar) then
spool Trigger_Mar_Sales_20
end;
Example 3, Tracking Inventory Level
Example 3 tracks the inventory level for the following product, region, and months
- Colas (product 100)
- Eastern region (market East)
- January, February, and March (the children of Qtr1)
The trigger is activated after the update action is complete. If the inventory of Colas in the eastern region falls below 500,000, the example logs an entry in the file Inventory_East.
create after update trigger Sample.Basic.Inventory_east
where "(crossjoin ({children([Qtr1])},
{([Market].[East], [Product].[100],
[Inventory].[Ending Inventory])}))"
when [Ending Inventory] < 500000 then
spool Inventory_East
end;