Applications need to query for INSTRUCTION and ACTIVITY in a given state. To simplify this recurrent task we will introduce two functions for this:
Returns the aggregated state of the given INSTRUCTION as a String
Returns the current state of the given ACTIVITY as a String
Some examples are:
FROM INSTRUCTION i
WHERE instruction-aggregate-state = 'ACTIVE'
FROM INSTRUCTION i CONTAINS ACTIVITY ac
WHERE current-state(ac) = 'ACTIVE'