[rules-users] In drools what is the exact difference between Insert and Update ??

Davide Sottara dsotty at gmail.com
Wed Mar 28 17:54:13 EDT 2012


Dear Bhushan, the recommendations you got from your architect should be
intended as best practices, not as strict instructions. Indeed, it depends
on what kind of rules you are writing and their business logic.

I agree that functions and globals should not be abused, and that salience
and groups should be intended as execution constraints, not as fine-grained
flow control, but I would reason on a case-by-case basis.

Now, as far as "update" is concerned... update is NEEDED to let the engine
know that some fact has changed. The only way not to use update is NOT TO
LET FACTS CHANGE. This is hardly possible in dynamic systems. 
In that case, the only alternative is to replicate and insert the facts with
different state identifiers (e.g. timestamps): Person( name=david, age=25 ),
Person( name=david, age=26 ), Person( name=david, age=27 ).....
This is indeed a purely declarative approach, which you pay with additional
logic - to select only the "current" facts - and additional memory
consumption.
If the reason for not using update is that rules fire when they shouldn't,
then I agree that no-loop is not the best choice. It works only for the same
rule where you do the update, so it's hardly a safe way to proceed. 
I would suggest, instead, to add constraints preventing the modified version
of the fact to trigger rules which have already fired. If you could provide
an example with one of your use cases, it would be easier to discuss the
pros and cons
Best
Davide

--
View this message in context: http://drools.46999.n3.nabble.com/In-drools-what-is-the-exact-difference-between-Insert-and-Update-tp3865471p3866107.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list