Hans Karlsen (talk | contribs) No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
Makes it possible use oclPS in any OCL expression. | |||
SomeClass.PSEvalValue(SomeClass.allinstances->select(x|x.name=vWhatever)->size,dependon) | Expression template | ||
SomeClass.PSEvalValue(SomeClass.allinstances->select(x|x.name=vWhatever)->size,dependon) | |||
Using this you can "reach into" the database from OCL and action-language (EAL) | |||
'''Note!''' - PSEval don't subscribe on 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 having "userName" as a parameter | |||
SysAsyncTicket.PSEvalValue(SysAsyncTicket.allInstances->select(at|at.Error.notNull)->size, Calendar.Now).asString | |||
The expression above will execute the a '''select count(*)''' on the table SysAsyncTicket with a where statement filtering on '''Error IS NOT NULL''' and the getting the value (number of rows). In the [[BaseApp]] model Calendar.Now updates every minute, which makes the count to reevaluate as long as this value is used. | |||
Always remember that your SQL-server might also need indexes and other performance settings to be able to execute your expression efficient. | |||
See also [[OCLOperators Sqlpassthrough|Sqlpassthrough]] |
Revision as of 17:31, 4 March 2022
Makes it possible use oclPS in any OCL expression.
Expression template
SomeClass.PSEvalValue(SomeClass.allinstances->select(x|x.name=vWhatever)->size,dependon)
Using this you can "reach into" the database from OCL and action-language (EAL)
Note! - PSEval don't subscribe on 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 having "userName" as a parameter
SysAsyncTicket.PSEvalValue(SysAsyncTicket.allInstances->select(at|at.Error.notNull)->size, Calendar.Now).asString
The expression above will execute the a select count(*) on the table SysAsyncTicket with a where statement filtering on Error IS NOT NULL and the getting the value (number of rows). In the BaseApp model Calendar.Now updates every minute, which makes the count to reevaluate as long as this value is used.
Always remember that your SQL-server might also need indexes and other performance settings to be able to execute your expression efficient.
See also Sqlpassthrough