Dynamic Business Rules
Hi,
I am trying to create a dynamic business rule through endeca developer studio. I have created a zone, style and a rule.
My rule doesn't contain any triggers and I have set it to "Everywhere". I have added a Featured records so that a particular record appears everytime. In Target tab, I have added a dimension value which is a Auto generated.
But when I run baseline_update I do not see any promoted records in my endeca_jspref page. Is there anything which I am missing to reflect the promoted records in my endeca_jspref page? Please help.
Thanks,
Sav
If you are using business rules I'm guessing you are on an earlier version of Endeca and/or not using Experience Manager. If so, is Workbench integration enabled and merch_rule_group_default.xml set up as a Workbench-managed file? You can see this in the "ConfigManager" component, property list of webStudioMaintainedFileX". If merch_rule is listed there, then the business rules configured via Developer Studio are ignored in favour of the ones set up in Workbench, so try running ./control/update_web_studio_config.sh, then adding the business rule via Workbench (http://<server>:8006/admin).
Michael
Similar Messages
-
Dynamic Business Rules - Where to place
Hi,
I am doing POC for a fortune 10 client and they have some business rules before crud actions are going to take place in DB. We have very minimal tables (less than 10) and its small application but web service (btw, this has to be webservice app) consumers are around 200 per sec.
The requirement with respect to business rules are also minimal (like 30 rules for entire project) but these rules will change very often(like once in a month). Assume these rules are on the enterprise level and not on the application level.
I am looking for best possible solution to achieve by developing small rules engine or putting them into another xml and apply transformation once request arrives.
I am confused of deciding which is better like putting business rules in xslt vs java business object. XSLT is allowing me to change rules with minimum impact on the system but it is hard to maintain and adding new rules (we are not anticipating any more new rules within next two years).
On the other hand, If I put in Java business object then it allows lot of flexibility to inject new rules and easy to maintain with cleaner code.
So, in short my questions are below.
1. Is it good practice to put small set of business rules in xml/xslt?
2.are there any alternative business rules engines are available?
Any other suggestion related to above discussions are welcome.
Thanks.I believe this is what you want.
DROOLS - drools - dynamic rules for java
http://sourceforge.net/project/showfiles.php?group_id=37037
http://www.onjava.com/pub/a/onjava/2005/08/03/drools.html?page=2
good luck. -
Conditional vs Business rule transitions
Any thoughts on when I should be using a business rule transition instead of a conditional? Any need to use this yet?
I understand the primary distinction is "dynamic" but am having a hard time getting my head around the difference without an example.
Cheers,
Andrew
AndrewAndrew,
I think business rules are mostly useful when modeling a condition that is likely to change, and you want to make it easy to change the condition on-the-fly, without having to change and re-deploy the process.
A simple example is when there is a transition that must be followed only when a variable value is above some predefined value (for example, a manager must approve all orders above $ 10K).
If using a business rule, this "10K" value can be easily changed as needed.
The ALBPM documentation has some guidelines on when to use Business Rules (section "When to use Dynamic Business Rules):
http://edocs.bea.com/albsi/docs60/studio/designer/business_rules_editor/t_Using_Dynamic_Business_Rules.html
My example is taken from the one in the document describing ALBPM 6.0 new features:
http://edocs.bea.com/albsi/docs60/resources/ALBPM6.0_NewFeaturesOverview.pdf
regards,
Eugenio -
Dynamic validation of Business Rules
Who has a good thought/example about a principle of dynamically validating Business Rules without coding every time each BR?
I am thinking about a table where I can enter the expressions like:
- <p1> is not Null
- <p1> not in (select 'x' from <table>)
- <p1> < 2000
This logically, simple expressions should return a boolean expression (true or false).First, in a well designed data model, I'm not sure I see the need for data validation logic to change regularly. If a particular column cannot be NULL today, it would be rather unlikely that it would somehow need to be NULL tomorrow.
Second, I'm not sure I see what this approach buys you over the much simpler approach of adding and removing check constraints if the data model changes. Adding and removing a constraint is pretty trivial-- orders of magnitude less difficult than doing the analysis to determine what constraint needs to change and what impact that has downstream.
Third, I would suspect that if you need to encode these sorts of constrains in a table, your system will kill downstream systems with regularity. If p1 is NOT NULL today, but tomorrow it suddenly allows NULL values, a consumer application might well break (or worse, silently return incorrect results). Data changes should not be able to screw up downstream systems.
Fourth, if you did build such a system, you would have to build your own constraint validator, rather than being able to rely on Oracle's (unless you wrote code to create and drop Oracle constraints based on values in a table, but that seems rather convoluted). Given that Oracle's constraint validation engine is highly optimmized and highly accurate, a home grown engine isn't going to look particularly good in comparison.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Dynamic filename in Business Rules
Hi,
I would like to use the DataExport command in my business rules to extract level-0 data in a file as a reference for user. I would need to extract data only for Entities that a user has access to (I figured that I could use parameters, link the rule to a Planning form and use "members" on form).
My problem is that I would need a different filename for each execution. Something like :
..\userABC_20090513_100350_BV_SBQ.txt
..\userDEF_20090513_100430_BV_SLVQ.txt
Is there a way, in business rules, to find the following info ?
- the user who is currently running the rule.
- the current date.
- the current time.
If not, is there a way to include a shell in a business rule. I have a small .exe that return the date or time as an "errorlevel" code that I could use if I can call a shell in the rule.
Finally, a theorical question : is there an other way to ensure that only the user who run the rule can access the generated file (always while using business rules) ?
ThanksFirst, in a well designed data model, I'm not sure I see the need for data validation logic to change regularly. If a particular column cannot be NULL today, it would be rather unlikely that it would somehow need to be NULL tomorrow.
Second, I'm not sure I see what this approach buys you over the much simpler approach of adding and removing check constraints if the data model changes. Adding and removing a constraint is pretty trivial-- orders of magnitude less difficult than doing the analysis to determine what constraint needs to change and what impact that has downstream.
Third, I would suspect that if you need to encode these sorts of constrains in a table, your system will kill downstream systems with regularity. If p1 is NOT NULL today, but tomorrow it suddenly allows NULL values, a consumer application might well break (or worse, silently return incorrect results). Data changes should not be able to screw up downstream systems.
Fourth, if you did build such a system, you would have to build your own constraint validator, rather than being able to rely on Oracle's (unless you wrote code to create and drop Oracle constraints based on values in a table, but that seems rather convoluted). Given that Oracle's constraint validation engine is highly optimmized and highly accurate, a home grown engine isn't going to look particularly good in comparison.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Rolling years dynamically updated from a business rule
Hi All,
Can anyone advise on how they have solved the problem of rolling opening balances from one year to another in essbase\planning. Our users could potentially want to forecast out x number of years and we don't want to necessarily hardcode out the business rule with each year. At them moment they are being prompted for the number of years that they will roll out and also the start and end year, they then have a business rule that loops the number of years and then fixes on the year range. This works however it will lead to performance issue going forward as the loop combined with the fix on the range will loop say 25 times for 5 years (5x5) instead of only 5 times.
Has anyone any pointers as to how to restrict this to only a year per pass or has anyone had this problem before ?
Thanks in advanceThanks,
We have prompts in already , the problem is that for our opening balances to flow through we need to calculate one year, then the next, then the next etc... but we don't know each time we run the business rule how many years we will forecast for (it is user dependant). Our code works but it loops on the whole subset of the years in range based on the user selection. -
Get cell value in Planning Data form and using it in a business rule
Hi Everybody,
if i set the data type of an Account Member as text, is there a way to get the value inserted by the user in a dataform, turning it as dimensional member and using it in a business rule?
So, if the user insert the value "USA" in a cell, can i use any functions to tell essbase that "USA" is a dimensional member and then using it in a business rule, for example in a cross-dimension like Period1->FY12->USA?
I tried to use the function @Member and it doesn't work, but i'm wondering if there is a way that can let me get the value inserted and use it just like a dimensional member. What are the ways that can let user input value that can be used in a business rule? I think one is by using SmartList, is there any other ways? Maybe using variables?? As an alternative i tried to use Prompt Variable but there are too many members on which the rule must run.
Please help me, i wanna know if i can or not let the user input the member on which the rule must run...
Thank all guys
Bye
MaurizioThanks EW for your answer,
YesI could use SmartList even if i think it's very tough to handle. My experience on using SmartList in caclc script is not so good. I try to enter in details of my requirement:
I have 500 account members.
For each one, I have to calculate the monthly budget by sharing the amount among the months. The user wants to calculate it on the basis of the actual flow(over the months) of an unspecified account of the prior year. The unspecified account must be inserted in a data form.
So, i could use a Smart List but it colud be of 500 elements and then i should make a rule with as many IF as how many are the accounts. Or im wrong? The only way to use smart list dynamically in a business rule is by referring its values in a IF condition. Or i'm wrong.
I tried to use execution variable ma it seems don't work. In this case the user must pay attention to write the account correctly, otherwise as you say the rule doesn't work.
The value in PD0A020 is "PD0A000" (that is a dimensional member). The value in PD0A000 is "hello". In PD0A040 the rule returns "PD0A000" and not "hello" as i would. The function @Member appears to be not able to catch the dimensional member by the value in PD0A000.
{Example}="test"->"Input"->"Scenario_test"->"FY12"->"PD0A020";
Fix("test1","Input","Scenario_test","FY12")
"PD0A040"=@Member({Example});
endfix
So, my doubt is: is it possible for Essbase/Planning to use the value inserted in a data form and to turn it in a dimensional member? What are the practicable ways to let the user input/choose the member on which makes the rule run?
Thank you Ew, thank you guys
Maurizio -
Error while executing business rule "Please increase CalcLockBlock setting"
Hello,
An error is occouring when I execute a particular business rule. The following message appears when I view the error from Job Console:
"Dynamic calc processor cannot allocate more than [100] blocks from the heap. Please increase CalcLockBlock setting and then retry"
No such error is occouring when I execute any other business rule.
Can anyone please tell me how to resolve it?
Regards,
Sa'adHi Sa'ad,
in the business rule your getting the error message is a calculation, where the result needs more than 100 blocks to access to.
The error comes from three possible causes:
1. Lockblock setting is low (essbase.cfg)
2. Your data cache setting is to small
3. Block size is to large
I think you have to increase data cache settings (by default 8192 KB) to.
Cheers
Uli
Edited by: Uli Drexelius on 13.07.2011 14:23 -
Hi,
is there a way to make the DataExport calcscript command works in Business Rules ?
I made the script below to export data in a calcscript and it works fine.
//ESS_LOCALE French_France.MS1252@Default
SET DATAEXPORTOPTIONS
DataExportLevel "LEVEL0";
DataExportRelationalFile ON;
DataExportOverwriteFile ON;
DataExportDecimal 2;
DATAEXPORTDIMHEADER OFF;
FIX ("Probables", "FY08","Officielle",@RELATIVE("E23",0));
DATAEXPORT "File" "," "D:\Hyperion\AnalyticServices_LTQuebec\APP\LTQuebec\Finance\Dump_Data\TestBV_SBQ.txt" "#MI";
ENDFIX;
The main objective is to have a level-0 file of all data for a specific version, scenario, year and entity. This file will be used (after modification like inluding alias and comments from Planning) as a reference by users.
Now, I would like to move it in a business rule to be able to pass parameters from a Planning form.
In my example "E23" is an entity and I would like it to change to follow user security in Planning (user will not be able to choose other entity than those they can access in Planning).
I tried to do it in a report but it is too slow as we have 12 dimensions, 3 of them having more than 1000 members.
Is anybody did something similar before (using DataExport or another method) ?
ThanksHi John,
my problem is not with DataExport performance, which is really fast (5 seconds or less). We have only level-0 members included in the export and none currently has dynamic calc.
The performance issue is with reports that take a long time to generate as we have 1000+ Activity * 1000+ Products * 1000+ Sectors so, basically 1,000,000,000 cells * the numbers of entities included. Last time I ran my test report, it ran for 6 hours before I killed it. Even with "Suppress Missing", it seems to try to extract all data first and remove missing after.
This is why we changed to DataExport, which is more efficient. But the fact that DataExport seems to be unrecognized by business rules cause me the problem that I can't use parameters and users will be able to see entities that are not their own (unless I create 200 scripts, one for each users, which will not really be a solution).
Thanks -
Using Y-T-D values in Business Rules
Hi All,
I am using Hyperion Planning 11.1.1.1.0.
I have enabled Y-T-D dynamic time series in the application.
I need to calculate YTD variance% , the formula to be used is :
(Y-T-D(Oct)Budget - Y-T-D(Oct) Actual) / Y-T-D(Oct)Budget * 100.
I have a business rule(created in EAS) that does the other variance % calculations which are pretty simple like Budget-Actual/Budget*100.
The formuls for the normal variance Percentage works but i get an error when writing a formula for :
"Variance%(YTDActual&YTDBudget)"
("Variance%(YTDActual&YTDBudget)"="Y-T-D(&CurrentMonth)"->Budget - "Y-T-D(&CurrentMonth)"->Actual / "Y-T-D(&CurrentMonth)"->Budget *100;)
The error that comes up is as follows:
Detail:Cannot calculate. Analytic Server Error(1200497): Error compiling formula for [Variance%(YTDActual&YTDBudget)] (line 2): unknown member name ["Y-T-D(&CurrentMonth)"] in function [operator @X]
Can somebody please advice as how to use Y-T-D values in the formulas?
Kind Regards.
MirkaHere are a couple of tips that may help:
1) You cannot directly reference dynamic-time-series members in a business rule or a member formula. These are "virtual" members. This is a common misconception.
2) Even if you could reference these members in a formula, you couldn't store a value in them anyway, as they are dynamic.
3) It usually doesn't make a lot of sense to calculate variances like these in a business rule. I would recommend making them dynamic, two-pass member formulas (not business rules) in your Scenario dimension. They don't need to be "Two pass" in the typical sense (eg. recalculating a ratio at the quarters), but they need to fire last, so set them as two pass. (otherwise you will end up with order of calculation issues where other calculations fire after the variance and you get incorrect results).
In looking at your requirement, you don't really need a variance that calls out dynamic time series members. Simply create a variance scenario with a formula like @VARPER("Budget", "Actual");. If you have "Y-T-D(Oct)" selected as your time period in your form or spreadsheet, and "Bud vs Act %" (this is your new variance scenario) selected, it will calculate the YTD variance for October, or whatever time period you have selected.
Just to recap:
1) Create a new scenario called "Bud vs Act %". Make it dynamic and two-pass. Give it a formula of @VARPER("Budget", "Actual");
2) Scrap your business rule. Add other variance scenarios as needed.
3) Add your YTD member and your variance scenario to a form, and test.
Hope this helps,
- Jake -
Problem with FIX-Statement in Business Rule
Hello,
ich have a business rule with two nested FIX-Statements.
I calculate depending on the month in the runtime-prompt a forecast for this month. After that i fix on that month an clear some specific accounts. But some of these accounts still have data.
they are in the cleardata section and they are children of FiBuKonten from the first fix. When i leave out the @CHILDREN("FiBuKonten") in the first fix the accounts are cleared as excepted, but i need that fix because not all accounts are part of this forecast.
I changed everything to work as a calc-script and the same problem appears, on dev and prod database.
Why are some accounts cleared while others not ? Really misterious!
Here is the rule
FIX([TEBIT_RTP_Year],[TEBIT_RTP_Version],"IFRS operativ",[TEBIT_RTP_Entity],"Daten brutto","Daten_brutto_P_M",@CHILDREN("FiBuKonten"))
[TEBIT_RTP_Period](
IF(@ISMBR("Jan"))
Actual_kum = Budget_kum;
ELSEIF(@ISMBR("Feb"))
Actual_kum = Budget_kum;
ELSEIF(@ISMBR("Apr"))
Actual_kum = @ROUND(("1HR"->Dec - Actual_kum->Mar)/9 + Actual_kum->Mar,2);
ELSEIF(@ISMBR("May"))
Actual_kum = @ROUND(("1HR"->Dec - Actual_kum->Apr)/8 + Actual_kum->Apr,2);
ELSEIF(@ISMBR("Jul"))
Actual_kum = @ROUND(("2HR"->Dec - Actual_kum->Jun)/6 + Actual_kum->Jun,2);
ELSEIF(@ISMBR("Aug"))
Actual_kum = @ROUND(("2HR"->Dec - Actual_kum->Jul)/5 + Actual_kum->Jul,2);
ELSEIF(@ISMBR("Oct"))
Actual_kum = @ROUND(("3HR"->Dec - Actual_kum->Sep)/3 + Actual_kum->Sep,2);
ELSEIF(@ISMBR("Nov"))
Actual_kum = @ROUND(("3HR"->Dec - Actual_kum->Oct)/2 + Actual_kum->Oct,2);
ENDIF;)
FIX([TEBIT_RTP_Period])
CLEARDATA "41000000";
CLEARDATA "41100000";
CLEARDATA "41200000";
CLEARDATA "41990000";
CLEARDATA "41000900";
CLEARDATA "41096000";
CLEARDATA "41196000";
CLEARDATA "41296000";
CLEARDATA "41940000";
CLEARDATA "42000000";
CLEARDATA "42100000";
CLEARDATA "42200000";
CLEARDATA "42099000";
CLEARDATA "42199000";
CLEARDATA "42299000";
CLEARDATA "42990000";
CLEARDATA "41918000";
CLEARDATA "41100900";
CLEARDATA "42091000";
CLEARDATA "42918000";
CLEARDATA "54000000";
CLEARDATA "54009000";
CLEARDATA "54009900";
CLEARDATA "54009600";
CLEARDATA "54130200";
CLEARDATA "93541175";
CLEARDATA "54001000";
CLEARDATA "54001900";
CLEARDATA "54014000";
CLEARDATA "54019000";
CLEARDATA "54021000";
CLEARDATA "54021900";
ENDFIX
ENDFIX
Thx for your help.
Greets
KevinDoes it make a difference when a dimension has dynamic calc members and i dont fix on that dimension to fix on the Level 0 members of that dimension ? The result should be the same in my eyes.
SGF is dense. I found out that everytime i the fix includes that first member M_124100 the error occoured.
I changed the rule in the form that i split the FIX Statement. And now it works without the error and with all data cleared. Even when i don`t reorder the dimension SGF.
Again thanks for your help.
Greets
Kevin
FIX([TEBIT_RTP_Year],[TEBIT_RTP_Version],"IFRS operativ",[TEBIT_RTP_Entity],"Daten brutto","Daten_brutto_P_M")
FIX(@CHILDREN("FiBuKonten"))
[TEBIT_RTP_Period](
IF(@ISMBR("Jan"))
Actual_kum = Budget_kum;
ELSEIF(@ISMBR("Feb"))
Actual_kum = Budget_kum;
ELSEIF(@ISMBR("Apr"))
Actual_kum = @ROUND(("1HR"->Dec - Actual_kum->Mar)/9 + Actual_kum->Mar,2);
ELSEIF(@ISMBR("May"))
Actual_kum = @ROUND(("1HR"->Dec - Actual_kum->Apr)/8 + Actual_kum->Apr,2);
ELSEIF(@ISMBR("Jul"))
Actual_kum = @ROUND(("2HR"->Dec - Actual_kum->Jun)/6 + Actual_kum->Jun,2);
ELSEIF(@ISMBR("Aug"))
Actual_kum = @ROUND(("2HR"->Dec - Actual_kum->Jul)/5 + Actual_kum->Jul,2);
ELSEIF(@ISMBR("Oct"))
Actual_kum = @ROUND(("3HR"->Dec - Actual_kum->Sep)/3 + Actual_kum->Sep,2);
ELSEIF(@ISMBR("Nov"))
Actual_kum = @ROUND(("3HR"->Dec - Actual_kum->Oct)/2 + Actual_kum->Oct,2);
ENDIF;)
ENDFIX
FIX([TEBIT_RTP_Period])
CLEARDATA "41000000";
CLEARDATA "41100000";
CLEARDATA "41200000";
CLEARDATA "41990000";
CLEARDATA "41000900";
CLEARDATA "41096000";
CLEARDATA "41196000";
CLEARDATA "41296000";
CLEARDATA "41940000";
CLEARDATA "42000000";
CLEARDATA "42100000";
CLEARDATA "42200000";
CLEARDATA "42099000";
CLEARDATA "42199000";
CLEARDATA "42299000";
CLEARDATA "42990000";
CLEARDATA "41918000";
CLEARDATA "41100900";
CLEARDATA "42091000";
CLEARDATA "42918000";
CLEARDATA "54000000";
CLEARDATA "54009000";
CLEARDATA "54009900";
CLEARDATA "54009600";
CLEARDATA "54130200";
CLEARDATA "93541175";
CLEARDATA "54001000";
CLEARDATA "54001900";
CLEARDATA "54014000";
CLEARDATA "54019000";
CLEARDATA "54021000";
CLEARDATA "54021900";
ENDFIX
ENDFIX -
How to create Business Rule?
Hi All,
i am new to Hyperion, can any one help me on the following issue.
i want to crate a business rule to aggregate data from level 0 to parent level for one partcula data form and aloso have to calculate the data for the following member
Cost per Unit = Total Revenue/Unit
i have already have the member formula in outline for cost per Unit as follows
Cost per Unit = Expense/Unit
How i can create the business ruleto calculate the data for cost per Unit (Total Revenu/Unit) and the aggregation of data to the parent level in data form
I have 12 dimensions and i am using 9.3.1 Version
Thanks in advance
Ram
Edited by: Ram on Sep 2, 2011 2:36 AMi want to crate a business rule to aggregate data from level 0 to parent level for one partcula data form^^^These are oldies but goodies:
http://camerons-blog-for-essbase-hackers.blogspot.com/2009/06/why-i-hate-and-love-business-rules-part.html
http://camerons-blog-for-essbase-hackers.blogspot.com/2009/06/why-i-hate-and-love-business-rules-part_17.html
Cost per Unit = Total Revenue/Unit^^^Are you asking if it makes sense to calculate this ratio at all levels of the database or only at the top level? If you mean that it only makes sense at level zero, you could use a FIX statement to select all level zero members and then perform the calculation. Based on the formula, I would think you could get away with a dynamically calculated member formula, assuming Total Revenue is dynamically calculated as well. Generally, level zero calcs in a business rule are only required if there's a percentage involved; if the formula is valid at aggregated levels, make it dynamic unless reporting performance (I have seen dense formulas that go across many, many blocks -- bad idea) falls off a cliff.
Regards,
Cameron Lackpour -
Solving "COMMIT business rules" on the database server
Headstart Oracle Designer related white paper
"CDM RuleFrame Overview: 6 Reasons to get Framed"
(at //otn.oracle.com/products/headstart/content.html) says:
"For a number of business rules it is not possible to implement these in the server
using traditional check constraints and database triggers. Below you can find two examples:
Example rule 1: An Order must have at least one Order Line ..."
But, one method exists that allows solving "COMMIT rules" completely on the database level.
That method consists of the possibility of delaying the checking of the declarative constraints (NOT NULL, Primary Key, Unique Key, Foreign Key, Check Constraints) until the commit
(that method was introduced first in the version 8.0.).
E.g. we add the field "num_emps" to the DEPT table, which always has the value of the number
of the belonging EMP rows and add DEFERRED CK which uses the values from that field:
ALTER TABLE dept ADD num_emps NUMBER DEFAULT 0 NOT NULL
UPDATE dept
SET num_emps = (SELECT COUNT (*) FROM emp WHERE emp.deptno = dept.deptno)
DELETE dept WHERE num_emps = 0
ALTER TABLE dept ADD CONSTRAINT dept_num_emps_ck CHECK (num_emps > 0) INITIALLY DEFERRED
Triggers that insure the solving of the server side "COMMIT rules" are fairly simple.
We need a packed variable that is set and reset in the EMP triggers and those value
is read in the bur_dept trigger (of course, we could have place the variable in the package
specification and change/read it directly, thus not needing the package body,
but this is a "cleaner" way to do it):
CREATE OR REPLACE PACKAGE pack IS
PROCEDURE set_flag;
PROCEDURE reset_flag;
FUNCTION dml_from_emp RETURN BOOLEAN;
END;
CREATE OR REPLACE PACKAGE BODY pack IS
m_dml_from_emp BOOLEAN := FALSE;
PROCEDURE set_flag IS
BEGIN
m_dml_from_emp := TRUE;
END;
PROCEDURE reset_flag IS
BEGIN
m_dml_from_emp := FALSE;
END;
FUNCTION dml_from_emp RETURN BOOLEAN IS
BEGIN
RETURN m_dml_from_emp;
END;
END;
CREATE OR REPLACE TRIGGER bir_dept
BEFORE INSERT ON dept
FOR EACH ROW
BEGIN
:NEW.num_emps := 0;
END;
CREATE OR REPLACE TRIGGER bur_dept
BEFORE UPDATE ON dept
FOR EACH ROW
BEGIN
IF :OLD.deptno <> :NEW.deptno THEN
RAISE_APPLICATION_ERROR (-20001, 'Can''t change deptno in DEPT!');
END IF;
-- only EMP trigger can change "num_emps" column
IF NOT pack.dml_from_emp THEN
:NEW.num_emps := :OLD.num_emps;
END IF;
END;
CREATE OR REPLACE TRIGGER air_emp
AFTER INSERT ON emp
FOR EACH ROW
BEGIN
pack.set_flag;
UPDATE dept
SET num_emps = num_emps + 1
WHERE deptno = :NEW.deptno;
pack.reset_flag;
END;
CREATE OR REPLACE TRIGGER aur_emp
AFTER UPDATE ON emp
FOR EACH ROW
BEGIN
IF NVL (:OLD.deptno, 0) <> NVL (:NEW.deptno, 0) THEN
pack.set_flag;
UPDATE dept
SET num_emps = num_emps - 1
WHERE deptno = :OLD.deptno;
UPDATE dept
SET num_emps = num_emps + 1
WHERE deptno = :NEW.deptno;
pack.reset_flag;
END IF;
END;
CREATE OR REPLACE TRIGGER adr_emp
AFTER DELETE ON emp
FOR EACH ROW
BEGIN
pack.set_flag;
UPDATE dept
SET num_emps = num_emps - 1
WHERE deptno = :OLD.deptno;
pack.reset_flag;
END;
If we insert a new DEPT without the belonging EMP, or delete all EMPs belonging to a certain DEPT, or move all EMPs of a certain DEPT, when the COMMIT is issued we get the following error:
ORA-02091: transaction rolled back
ORA-02290: check constraint (SCOTT.DEPT_NUM_EMPS_CK) violated
Disvantage is that one "auxiliary" column is (mostly) needed for each "COMMIT rule".
If we'd like to add another "COMMIT rule" to the DEPT table, like:
"SUM (sal) FROM emp WHERE deptno = p_deptno must be <= p_max_dept_sal"
we would have to add another column, like "dept_sal".
CDM RuleFrame advantage is that it does not force us to add "auxiliary" columns.
We must emphasize that in real life we would not write PL/SQL code directly in the database triggers, but in packages, nor would we directly use RAISE_APPLICATION_ERROR.
It is written this way in this sample only for the code clarity purpose.
Regards
Zlatko SiroticZlatko,
You are right, your method is a way to implement "COMMIT rules" completely on the database level.
As you said yourself, disadvantage is that you need an extra column for each such rule,
while with CDM RuleFrame this is not necessary.
A few remarks:
- By adding an auxiliary column (like NUM_EMPS in the DEPT table) for each "COMMIT rule",
you effectively change the type of the rule from Dynamic (depending on the type of operation)
to a combination of Change Event (for updating NUM_EMPS) and Static (deferred check constraint on NUM_EMPS).
- Deferred database constraints have the following disadvantages:
When something goes wrong within the transaction, then the complete transaction is rolled back, not just the piece that went
wrong. Therefore, it becomes more important to use appropriate commit units.
There is no report of the exact row responsible for the violation nor are further violations either by other rows or of other
constraints reported.
If you use Oracle Forms as a front end application, the errors raised from deferred constraints are not handled very well.
- CDM discourages the use of check constraints. One of the reasons is, that when all tuple rules are placed in the CAPI,
any violations can be reported at the end of the transaction level together with all other rule violations.
A violated check constraint would abort the transaction right away, without the possibility of reporting back other rule violations.
So I think your tip is a good alternative if for some reason you cannot use CDM RuleFrame,
but you'd miss out on all the other advantages of RuleFrame that are mentioned in the paper!
kind regards, Sandra -
Oracle Rules Manager vs Oracle Business Rules
Hi
Can someone explain the difference between Oracle Rules Manager and Oracle Business Rules.
Is Oracle Promoting both the products?
What I understand is that Oracle Rules Manager comes a part of the Oracle Database 10g R2 (and 11g) and Oracle Business Rules is a part of the SOA suite.
Is there any difference in the positioning of both these products?
Our client is evaluating various Rules engines in the market and we want to make sure that we choose the correct product.
Thanks, SriniIgor S. wrote:
He solves the same problem with rules and without. My question was what would be better? Why would you chose one over the other. I prefer rules that is easy to state, easy to read, and easy to implement. Clear text rules in Prolog being a firm favourite. :-)
Using a rules engine, with a fairly complex API, in order to define rules? I would want very sound and very robust justification for that.
Taking this EMP table example. If there is a single AddEmp() PL/SQL procedure interface for adding employees, it is simple matter to see what it does, how it does that, and test and debug that. The only knowledge needed is the ability to read and understand the source code. The same cannot be said of rules engines.
As for the issue of updating AddEmp() with new rules. Edition redefinition takes care of versioning database objects. And in a far more controlled fashion than dealing with a rules engine that is dynamically update now! while the database is in use - and you have no real idea or real control over when exactly now! was. -
I wasn't sure where to post this, but:
Let's say I have boolean code sitting in a file on my computer that probably runs in java... :)
I want to read the file into my program and use its boolean code to decide whether or not to do things (since there are many different types of business rules, but some of the same things are happening just at different times). The code doesn't really stop to recompile, after reading it, the program just uses the newly uploaded code.
Is this possible, where would I find resources for this, what is it called? Any ideas would be appreciated....yeah all your comments were ridiculously helpful, not looking for more clearificationOk, fine. You go off and use the Java compiler tooling to do this. Then when you find out that the solution is non portable and doesn't really help with whatever your "real" problem is, that's all your problem.
, looking for different ways, "names" of methods.Ok. Use Google. Seriously, if you know enough about this problem to know you need to dynamically compile source code, you must know enough to find the solution using Google. You don't need my help.
If you do need help, then by definition you don't know everything about the problem. In which case you don't know that this is the best solution. But I can't help you find the best solution unless you tell me the problem you're trying to solve instead of the solution you've selected but can't actually achieve.
It's not my problem either way.
Maybe you are looking for
-
How to use at new in alv report
Hi Experts, I am creating a ALV report in which i have to sorted the data with 1 field like " if there the one division that have multiple department , so i have to show the output like division name then next row contain the releted dept of that" ca
-
Cannot select multiple speakers ( airport express)
cannot select multiple speakers in itunes ( have two airport expresses) ... tries to connect and then always times out.
-
Org Unit and Cost Center not displaying in 0001 with A012 relationship
Hi Guru's, Kindly help me in this regard , Whenever i hire a person to a position which has an A012 relationship (Chief Position) then Org Units and Cost centres are not getting displayed in IT0001 . But when i hire a person in the same org unit with
-
Cannot install adobe reader on MacBook
I keep trying to install the lastest version of adobe reader and it will not accept my password. Is this an Apple issue? I own a MacBook Pro. Thanks, Tara
-
I think the WSCONFIG folder for other site is 2 and I created VD jakarta to point to 2. for the site I am seeing issue - it is pointing to 1 and seeing some restriction file. I tried to create multiple times new site so it creates and point to new fo