Working of Oracle Business Rules

Hello,
We are trying to evaluate Oracle Buiness Rules packaged with 10gIAS 10.1.3. We are playing around with how-to-rules-java/vehicleRent demo and created following set of rules. We are not able explain the output of TestMain.java program. Couldn't find any documentation around how internally it evaluates the rules!
Can you pls help us understand the behaviour?
Ruleset: RL
========
1. ruleset vehicleRent
2.
3. {
4.
5. rule UnderAge
6. {
7. priority = 4;
8. if
9. (
10. (
11. fact carrental.Driver v0_Driver && (
12. (v0_Driver.age >= 15)) &&
13. fact carrental.Driver v1_Driver && (
14. (v1_Driver.age > 40)))
15. )
16.
17. {
18. DM.println("Rule 1 - "+v0_Driver.getAge());
19. v1_Driver.age = v1_Driver.getAge()+10;
20. }
21. } //end rule UnderAge;
22.
23. rule MatchAge
24. {
25. priority = 1;
26. if
27. (
28. (
29. fact carrental.Driver v0_Driver && (
30. (v0_Driver.age > 45)))
31. )
32.
33. {
34. DM.println("Rule 2 - "+v0_Driver.getAge());
35. }
36. } //end rule MatchAge;
37.
38. rule AgainMatchAge
39. {
40. priority = 0;
41. if
42. (
43. (
44. fact carrental.Driver v0_Driver && (
45. (v0_Driver.age > 43)))
46. )
47.
48. {
49. DM.println("Rule 3 - "+v0_Driver.getAge());
50. }
51. } //end rule AgainMatchAge;
52.
53. rule RetractRule
54. {
55. priority = 3;
56. if
57. (
58. (
59. fact carrental.Driver v0_Driver && (
60. ((v0_Driver.age <= 44) && (v0_Driver.age > 40))))
61. )
62.
63. {
64. DM.println("Retracting age: "+v0_Driver.age);
65. retract( v0_Driver );
66. ;
67. }
68. } //end rule RetractRule;
69. }// end ruleset vehicleRent
TestMain.java
==========
Date daveLicIssueDate = getDate( "10/1/1969" );
Driver d1 = new Driver( "d111", "Dave", 50, "sports", "full",
daveLicIssueDate, 0, 1, true );
//assert driver qun, will NOT satify the rule
Date qunLicIssueDate = getDate( "8/1/2004" );
Driver d2 = new Driver( "d222", "Qun", 15, "truck", "provisional",
qunLicIssueDate, 0, 0, true );
//assert driver lance
Date lanceLicIssueDate = getDate( "6/1/2004" );
Driver d3 = new Driver( "d333", "Lance", 44, "motorcycle", "full",
lanceLicIssueDate, 0, 1, true );
session.callFunctionWithArgument( "assert", d1 );
session.callFunctionWithArgument( "assert", d2 );
session.callFunctionWithArgument( "assert", d3 );
session.callFunctionWithArgument( "run", rsname );
=====================
OUTPUT:
=======
Rule 1 - 44
Rule 1 - 15
Rule 1 - 64
Rule 1 - 60
Rule 1 - 15
Rule 1 - 70
Retracting age: 74
Rule 2 - 80
Rule 3 - 80

Some documentation text:
Many users are surprised by the results for the following code:
class F {int i; };
rule r1 {
if (fact F F1 && fact F F2) {
println("Results: " + F1.i + ", " + F2.i);
assert(new F(i:1));
assert(new F(i:2));
run();
How many lines will be printed? The answer is 4 lines because fact F1 and
fact F2 can be the same instance and will be compared in each operand. Thus,
the example above results in the following output:
Results: 2, 2
Results: 2, 1
Results: 1, 2
Results: 1, 1
Of course if a third F is constructed (e.g. assert(new F(i:3));) then nine
lines will be printed and if, at the same time, a third term && fact F F3 is
added than 27 lines will be printed.
If the user is attempting to find all combinations and orders of distinct facts, they must add and additional term to the test:
rule r1 {
if (fact F F1 && fact F F2 && F1 != F2) {
println("Results: " + F1.i + ", " + F2.i);
This would then print out:
Results: 2, 1
Results: 1, 2
The simplest (although not the fasted) way to find all combinations of facts, regardless of their order, is to use:
rule r1 {
if (fact F F1 && fact F F2 && id(F1) < id(F2)) {
println("Results: " + F1.i + ", " + F2.i);
Because the function id() takes longer to execute in test pattern than a direct comparison, the fastest method is to test on a unique value in each object. For example, you could add an integer value property “oid” to your class that is assigned a unique value for each instance of the class. The rule using this would look like:
rule r1 {
if (fact F F1 && fact F F2 && F1.oid < F2.oid) {
println("Results: " + F1.i + ", " + F2.i);
This problem may also arise if the user attempt to remove all duplicate facts from the rule engine. They may initially write a function like:
rule rRemoveDups {
if (fact F F1 && fact F F2 && F1.i = F2.i) {
retract(F2);
However, this rule will remove all facts of type F, not just the duplicates because F1 and F2 may be the same fact instance. The correct version of this rule is:
rule rRemoveDups {
if (fact F F1 && fact F F2 && F1 != F2 && F1.i = F2.i) {
retract(F2);
}

Similar Messages

  • How to make BPEL process work with  Oracle Business Rules

    Hi
    I know that we can use business rules in BPEL process as decision services.
    But how should I do in real development? Are there any samples or tutorials that explain how to do that in details on otn or somewhere?
    Could somebody help?
    Thanks a lot
    Peter

    Thanks a million.
    But I have an other problem now.
    That is my JDevelper has no Decision service activity. And I saw the list label name is BPEL Extension Activities. But my JDev has no such a list item. What should I do?
    Hope somebody could help me!
    Thanks
    Peter

  • Oracle Business Rules with Fusion Release 4

    Hi
    I am wondering if we can use the Oracle Business Rules product with the Oracle Fusion Compensation APplication Release 4.
    Thanks
    Srinivasa Sunchu

    Srinivasa,
    There are relevant chapters in the Oracle Fusion Middleware User's Guide for Oracle Business Rules. There is sample code interspersed in the chapters.
    7 Working with Rules SDK Decision Point API
    http://fmwdocs.us.oracle.com/vol/doclibs/fusionapps/review/E36909_01/user.1111/e10228/decision_point.htm#ASRUG455
    10 Working with Oracle Business Rules and ADF Business Components
    http://fmwdocs.us.oracle.com/vol/doclibs/fusionapps/review/E36909_01/user.1111/e10228/adfbc.htm#ASRUG378
    I looked through the source code of one of our products that uses the Rules SDK to see if there is an easy-to-extract example, but it's far beyond the scope of a forum post. We'll probably create one or more blog posts that dive deeper into this topic, but I cannot promise a date for that. Keep an eye on http://blogs.oracle.com/fadevrel please.

  • Not able to access the web based RuleAuthor of Oracle Business Rules

    Hi ,
    I have Installed Oracle SOA Suite (11g) version from here .
    I have followed the steps in the Installation guide .
    I was able to install it successfully. At present I need to Work on the oracle Business Rules.
    As per the documentation I have tried to access the Rules author at the following URL
    http://localhost:7001/ruleauthor/
    But I was not able to access it.
    Please let me know if I need to install any other component to access Rule Author. please let me know if you need any more information.
    Thanks in advance for your time,
    Raja Kumar

    Back up all data.
    Launch the Keychain Access application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Keychain Access in the icon grid.
    Select the login keychain from the list on the left side of the Keychain Access window. If your default keychain has a different name, select that.
    If the lock icon in the top left corner of the window shows that the keychain is locked, click to unlock it. You'll be prompted for the keychain password, which is the same as your login password, unless you've changed it.
    Right-click or control-click the login entry in the list. From the menu that pops up, select Change Settings for Keychain "login". In the sheet that opens, uncheck both boxes, if not already unchecked.
    From the menu bar, select
    Keychain Access ▹ Preferences ▹ First Aid
    If the box marked Keep login keychain unlocked is not checked, check it.
    Select
    Keychain Access ▹ Keychain First Aid
    from the menu bar and repair the keychain. Quit Keychain Access.

  • Oracle RDF and Oracle Business Rules & Protege

    A couple of questions:
    1.) Has anyone used Protege to create frame-based ontologies which can somehow be used with Oracle Business Rules?
    2.) Has anyone used Protege along with the RDF storage functionality in Oracle?
    Thanks.

    Melli,
    I just started with semantic so won't have many useful ideas for at least some time.
    mostly there will be bugs and misunderstanding on my part.
    At this point i do see that the supplied library is not working properly . see my other thread. Fixing that would be really helpful.
    Let me know
    As of Composer - well let's just say its cost ineffective for organization to use on pilot project..

  • Query on handling else condition in Oracle Business Rules.

    Hi all.
    I am working on Jdeveloper 11.1.1.1.0 Business Rules. While creating rules... i am able to write if conditions around the facts and attributes and also replicate the same using decision tables and is able to derive the action.
    My Question is.. can i write an else condition which should be executed when none of the if condition are matched. If we can how... Instead of else condition, is there any way that we can initialize the facts and attributes to be derived to a default value.
    Please help me guys in this... If this is not the right foru,... please redirect me to the correct one.. coz i couldnt find a forum for oracle business rules..
    Thanks
    Eldho

    Thanks a lot for the response..
    I have posted the query in
    Query on handling else condition in Oracle Business Rules.
    Thanks
    Eldho

  • Syntax errors in Oracle Business Rules carrental ruleset

    Hi,
    I'm using Oracle Business Rules Rule Author on Windows, version 10.1.3.0.0.
    I'm working with the OTN carrental sample. If i load the supplied file-based repository CarRepository from the %HOWTO_HOME%/dict directory, navigate to the RL tab -> Generate RL-code and select the 'Check RL-Syntax' button I always get the same error message:
    Error:'5}' is undefined at line ... column ... in [DM or vehicleRent]
    If I navigate to 'Test Rulesets' i get the same error, no matter what testfunction i use with the vehicleRent ruleset.
    When i test the sample with the supplied java code i don't get any errors.
    However, if I follow the steps in chapter 2 (javaFact) or 4 (XMLFact) of the Business Rules user guide and setup everything from scratch for a filebased repository i get the same error at runtime.
    I based the filebased repository on the supplied emptyrepository file.
    Seems to make no difference whether I use a filebased or a webdav repository.
    any help on this would be appreciated.
    Rob
    Message was edited by:
    [email protected]

    There are two problems here. First, there is a bug that causes this error string to be displayed incorrectly when using the RuleAuthor in any browser language other than English. If you change the browser language to English, you should see:
    <p>
    A syntax error is found. <br>
    Error:'carrental.Driver' is undefined at line 4 column 14 in DM
    <p>
    The cause of this problem is that carrental.Driver class is not in the classpath for Rule Author. This isn't covered in the how-to. See section 3.10 in the Oracle® Business Rules User’s Guide (B15986-01) (available from here).
    <p>
    From this doc:
    <p>
    Create a rule set you want to test. If the data model includes any Java classes, the
    Java classes must be included in the OC4J classpath. The easiest way to do this is
    to put the JAR files in the following directory, then restart OC4J:
    $ORACLE_HOME/j2ee/home/applications/ruleauthor/lib
    <p>
    or add it as a shared library using EM (specific instructions follow in the doc) and then add that shared library to RuleAuthor.
    Message was edited by:
    philvarner

  • Xpath and oracle business rules

    Hi; are there any examples that demonstrate using XPath in a rule?
    Any comments on whether oracle business rules might be a valid choice for an application that needs to enforce a set of, and varying, constraints on an incoming XML document.
    Thanks for the info.
    -Tim Watson

    The XPath support in the current version of Rules is for asserting portions (or all) of an XML document as facts. The Rules are then written against the elements in the XML that you are interested in.
    I can't say for sure without more details, but Rules would work for enforcing constraints on XML documents.

  • JHeadstart, Oracle Business Rules and BPEL Process Manager

    Dear JHeadstart Team,
    I have some questions regarding integration of JHeadstart and Oracle Business Rules and Oracle BPEL Process Manager. As a matter of fact I don't have any work expriences with these tools so my questions may not be good and precise.
    1- Using a business rule engine can dramatically increase speed of development and ease of maintenance.I had a very good exprience in using JHeadstart and Headstart in the past but I wanted to know if it is possible to use Oracle Business Rules in conjunction with the JHeadstart ? If so, What steps should be taken? Is there any known issue about this integration? Does Oracle Business Rules have any interference with JHeadstart or it is only used in model layer during insert,update,delete?
    2- Is it possible to develope a system based on oracle work flow engine (Oracle BPEL Process Manager) using JHeadstart ? If so, What steps should be taken and how the changes in the flow of work would by applyed in a system developed by JHeadstart. Is there any known issue about this integration?
    Any help,link to documents or general guidelines would be highly appreciated.
    Thanks in advance,
    Navid

    Couple of things I would like to add, are the following.
    In the context of an ADF application usage of Oracle Business Rules most likely is in the business logic layer, but mind that it does not need to be restricted to that.
    Oracle Business Rules takes so called 'facts' as input, evaluates some rules based on that and change those facts or return some result. That might be checking a business rule as defined in the JHeadstart Developers Guide. But it might also return some value that is used in a navigation rule.
    Think about a page flow where after page A normally page C is presentend, but in case of some situation (like a customer ordered something and you want to present some special offering based on that) you want page B presented in between (i.e. A -> B -> C). Oracle Rules could be used to determine this page flow. This would be an example of using it in the controller layer (probably in combination with using facts that come from the model layer).
    Another remark that I would like to make, is that in my opinion it does not make much sense to use Oracle Rules for business rules that logically more or less are part of your data model (like end date must be on or after begin date). You typically use Oracle Rules to implement business rules that are of a volatile nature, meaning that day-to-day business may require a change of the rules. One example is the navigation case that I mentioned before. Another (typical) example would be a rule that defines when a customer is a Gold customer.
    Jan Kettenis

  • Oracle Business Rules Rule Author

    Hi,
    Iam implementing Oracle Business Rules, while configuring rules with Rule Author, a problem is faced, a variable data which is set in one rule's action is not available to next rule's condition.
    i.e a variable set in one rule can not be used in other rule as condition.
    Is there any option to make it work,
    thanks & regards.
    anil

    I took the CarRental Java model and exposed two more attributes namely numPreConvictions and ableToDrive. Then I fed it a fact where the driver has 4 convictions and ableToDrive=true. When I ran it in the rule author tester it ran out of memory indicating it may have gone into a loop. I must be missing something here. The test RL function is below the rule set code.
    In my other test from outside the rule author it just won't fire the second rule (no out of memory issue). For that one I have a metalink SR 6560804.992 waiting for response. I attached some code to that one too. I got that one to work via Java Beans property change support.
    1. ruleset reAssertTest
    2.
    3. {
    4.
    5. rule checkConvictions
    6. {
    7. priority = 0;
    8. if
    9. (
    10. (
    11. fact carrental.Driver v0_Driver && (
    12. (v0_Driver.numPreConvictions > 2)))
    13. )
    14.
    15. {
    16. v0_Driver.ableToDrive = false;
    17. DM.println(v0_Driver.name+" has more than 2 convictions. set able to drive=false and re-assert ");
    18. assert(v0_Driver);
    19. }
    20. } //end rule checkConvictions;
    21.
    22. rule cannotDrive
    23. {
    24. priority = 0;
    25. if
    26. (
    27. (
    28. fact carrental.Driver v0_Driver && (
    29. (v0_Driver.ableToDrive == false)))
    30. )
    31.
    32. {
    33. DM.println(v0_Driver.name+" cannot drive");
    34. }
    35. } //end rule cannotDrive;
    36. }// end ruleset reAssertTest
    -- reAssertTest ---
    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat( "MM/dd/yyyy" );
    assert (new carrental.Driver( "d111", "Dave", 50, "sports", "full",
    sdf.parse ("10/1/1969"), 4, 4, true ));
    pushRuleset ("reAssertTest");
    run();
    ---------------

  • Oracle Rule Author(Oracle Business Rules)

    Hi,
    Iam implementing Oracle Business Rules, while configuring rules with Rule Author, a problem is faced, a variable data which is set in one rule's action is not available to next rule's condition.
    i.e a variable set in one rule can not be used in other rule as condition.
    Is there any option to make it work,
    thanks & regards.
    anil

    I think you would get better response on the question if you post the same question to the SOA Suite forum (SOA Suite
    A

  • Using third party jars with Oracle Business Rules

    Hi
    I am working on Oracle AS 10g release 2.
    We are using Oracle Business Rules in integration with Oracle BPEL.
    While using third party jars however, Oracle Business Rules end is facing errors.
    Error during unmarshallingProvider com.sun.xml.bind.ContextFactory_1_0_1 not found
    oracle.classloader.util.AnnotatedClassNotFoundException:
    Missing class: com.sun.xml.bind.ContextFactory_1_0_1
    Dependent class: javax.xml.bind.ContextFinder
    Loader: oracle.xml:10.1.0_2
    Code-Source: /D:/oracleasr3/lib/xml.jar
    Configuration: <code-source> (ignore manifest Class-Path) in META-INF/boot.xml in D:\oracleasr3\j2ee\home\oc4j.jar
    Can anybody help in figuring out where Jaxb jars(3rd party jars) are to be kept so that OAS access it?
    We tried using the applib folder to load the jars but we are getting class loading errors.
    When new instances are created, class loading is not happening.
    Pls help.
    Thanks
    Kavya

    Are you using Application Server Release 3 or Release 2? There are different versions listed in your mail.
    I think you probably want to add this as a shared library via EM and then import the shared library to your application with the application's xml config files.

  • ODI and Oracle Business Rules

    Hi, I have a question that hopefully someone can give light to.
    Our current requirement for an ODI solution is to have business users create or edit rules (not just table constraints, but actual complex business process rules) that they would like to apply to the data during integration. I was thinking of two possibilities for this:
    1. Load a rule file in ODI and then execute the rules in ODI.
    2. Use Oracle Business Rule.
    Between the two options, which is most likely possible? I have yet to fully explore ODI so I'm not sure if both of these options are feasible. If not, can someone give me sound ideas to work on for this requirement?
    Thanks,
    Jason

    Melli,
    I just started with semantic so won't have many useful ideas for at least some time.
    mostly there will be bugs and misunderstanding on my part.
    At this point i do see that the supplied library is not working properly . see my other thread. Fixing that would be really helpful.
    Let me know
    As of Composer - well let's just say its cost ineffective for organization to use on pilot project..

  • How to use  create & ruleExecutionSet in oracle business rules

    I am trying to run the demo example of oracle business rule (car demo) using
    ruleExecutionSet.
    What are the changes thet i have to made in example in order to create & use the ruleExecutionSet to run the car demo .
    with regards
    saleem khan

    you are in the Oracle Forms Forum and your question is related to JDeveloper and Crystal Reports, you think those two are linked to Oracle Forms in anyway??
    Please post your questions in the appropriate Forum.
    Tony

  • Problem in mapping Task payload parameters to Oracle Business Rules facts

    Hi all,
    We are using complex types from our project XSDs inside the Human Task payload. We intend to use these Human Task payload parameters to build routing rules using the Oracle Business Rules interface. Our observation is that when the complexity of these complex types increase, the business rules editor does not show these as facts that can be used in formulating rules.
    Has anybody faced such a problem before. Any help is appreciated.
    We are using the following link to add routing rules –
    http://docs.oracle.com/cd/E25054_01/dev.1111/e10224/bp_decision.htm
    Version details :
    ADF Business Components     11.1.1.60.13
    Java(TM) Platform     1.6.0_29
    Oracle IDE     11.1.1.5.37.60.13
    SOA Composite Editor     11.1.1.5.0.01.74
    Thanks,
    Yamini.

    Problem solved. There was an element in the xml schema that had nillable = true. Because of this the XML Fact for that element would no longer be available in the BPEL Process. Removing the nillable and generating the XML Facts again solved the missing variable problem.

Maybe you are looking for

  • Where is the file sharing section located in iTunes 12?

    I am trying to open up an iMovie Project that I sent to iTunes from my iPhone 4s. After the project exported my phone said "Send to iTunes Complete. Your project will appear in the File Sharing section of iTunes as: Horror short." But, I can't find t

  • Purchase order does not update tax code in info recode ?

    Hi Expert, Please help me ........... I have 2 problems. 1. I created PO and tick Infoupdate at ME21N but tax code doesn't update to info record ? 2. How to tax code can be defaulted into PO line items by I don't want create info recode ? Thanks,

  • Weird question in SSIS 2012 package

    hi folks:   I've created a SSIS 2012 package in my local machine using  Microsoft SQL Server Integration Services Designer Version 11.0.3436.0 This package contains a script task using .NET framework 4 .  Everything works fine and I decided to deploy

  • Oracle 10g Companion CD installation

    I have installed Oracle 10g database rel 10.1.0 on Digital TRU64 Unix. I want to know whether the database should be opened or closed for installing Oracle10g Companion CD. I am intending to install only JVM related stuff.

  • Sales By Month Query

    Hello - Any way to adjust the below query to also include Credit Memo / Returned Items? Also, does it include freight amt? SELECT T0.State1 AS 'Bill-to State', (SELECT SUM(T1.DocTotal) FROM OINV T1 with (NOLOCK) INNER JOIN OCRD T2 ON T2.CardCode=T1.C