OCLOperator PSEvalValue makes it possible to use oclPS in any OCL expression.
Using this, you can "reach into" the database from OCL and action-language (EAL).
Note! PSEval doesn't subscribe to the value from the DB. To make the operator auto-updating, provide an expression in "dependon" that, when changed, should also rerun the PSEval expression. This can, for example, be a timer.
For example, this expression from a method has "userName" as a parameter:
The expression above will execute the select count(*) on the table SysAsyncTicket with a where statement filtering on Error IS NOT NULL and then getting the value (number of rows). In the BaseApp model, Calendar.Now updates every minute, which makes the count reevaluate as long as this value is used.
Always remember that your SQL-server might also need indexes and other performance settings to execute your expression efficiently.