Another approach would be to use a transient Fact for the "local variable":-

rule "1"
when
        #some condition01
then
        insertLogical( new MyFact(200) );
end

rule "2"
when
       #some condition02
then
        insertLogical( new MyFact(300) );
end

rule "3"
when
     #some condition03
     MyFact( $v : value )
then
     emp.salary=$v+2000
end

Of course if Rule "1" and Rule "2" both inserted an instance of MyFact Rule "3" would activate twice. This can be safe-guarded against by checking for the non-existence of MyFact:-

rule "1"
when
        #some condition01
        not MyFact()
then
        insertLogical( new MyFact(200) );
end

rule "2"
when
       #some condition02
        not MyFact()
then
        insertLogical( new MyFact(300) );
end

rule "3"
when
     #some condition03
     MyFact( $v : value )
then
     emp.salary=$v+2000
end

If however you then needed this to work on, for example different employees, you'd need to associated MyFact to the employee:-

rule "1"
when
        $e : Employee( position == "grunt" )
        not MyFact( employee == $e )
then
        insertLogical( new MyFact(200, $e) );
end

rule "2"
when
        $e : Employee( position == "manager" )
        not MyFact( employee == $e )
then
        insertLogical( new MyFact(300) );
end

rule "3"
when
     $e : Employee( position == "grunt" )
     MyFact( $v : value, employee == $e )
then
     modify($e) {
          setSalary( $v+2000)
     }
end


On 5 October 2012 12:46, joy <Kripa_M01@infosys.com> wrote:
Hi

i need local variables in drl file.
it should hold integer/double value.
Setting an integer value to a local variable in some rule and getting that
integer value in some other rule

when
        #some condition01
then
        local variable=200
end

when
       #some condition02
then
       local variable =300
end

when
     #some condition03
then
     emp.salary=localvariable+2000
end

Anyone plz help me to resolve this.

Thank you
Joy




--
View this message in context: http://drools.46999.n3.nabble.com/Local-Variable-tp4020144.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users