OCLOperators PSEval
No edit summary
No edit summary
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
A way to switch from ocl to oclps in any expression.
The OCLOperator PSEval makes it possible to use oclPS in any OCL expression. Using this, you can "reach into" the database from OCL and action-language (EAL).


SomeClass.PSEval(SomeClass.allinstances->select(x|x.name=vWhatever),maxfetch,offset,dependon) -  offers a way to reach into the database from ocl and action-lang - beware that we dont subscribe on sets from db, send things to subscribe on dependon.
Expression template:
SomeClass.PSEval(<ps-expression>,maxfetch,offset,<dependon>)
'''Note!''' PSEval doesn't subscribe to sets from 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
'''Warning!''' Remember that using PSEval means that no changes to the result set content will be fetched automatically. This breaks the very nice subscription feature built into the framework for that data.
 
'''Note!''' Offset is 0-based.
 
Example:
Uppdrag.PSEval(self.Uppdrag->select(u|u.Aktivt)->orderDescending(u|u.Startdatum),  1000, 0, self.Uppdrag)
For example, this expression from a method has "userName" as a parameter:
  SysUser.PSEval(SysUser.allinstances->select(su|su.Username=userName),2,0,<nowiki>''</nowiki>)
  SysUser.PSEval(SysUser.allinstances->select(su|su.Username=userName),2,0,<nowiki>''</nowiki>)
See also [[OCLOperators Sqlpassthrough|Sqlpassthrough]]
Always remember that your SQL-server might also need indexes and other performance settings to execute your expression efficiently.
 
'''Note!''' The offset parameter should almost always be 0, if not used to show a seconds page in a pagination or similar.
 
See also: [[OCLOperators Sqlpassthrough|Sqlpassthrough]], [[OCLOperators PSEvalValue|PSEvalValue]], [[Documentation:OCLOperators PSEvalTuples|PSEvalTuples]]
[[Category:OCLOperators]]
{{Edited|July|12|2024}}

Latest revision as of 05:37, 4 June 2024

The OCLOperator PSEval makes it possible to use oclPS in any OCL expression. Using this, you can "reach into" the database from OCL and action-language (EAL).

Expression template:

SomeClass.PSEval(<ps-expression>,maxfetch,offset,<dependon>)

Note! PSEval doesn't subscribe to sets from 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.

Warning! Remember that using PSEval means that no changes to the result set content will be fetched automatically. This breaks the very nice subscription feature built into the framework for that data.

Note! Offset is 0-based.

Example:

Uppdrag.PSEval(self.Uppdrag->select(u|u.Aktivt)->orderDescending(u|u.Startdatum),  1000, 0, self.Uppdrag)

For example, this expression from a method has "userName" as a parameter:

SysUser.PSEval(SysUser.allinstances->select(su|su.Username=userName),2,0,'')

Always remember that your SQL-server might also need indexes and other performance settings to execute your expression efficiently.

Note! The offset parameter should almost always be 0, if not used to show a seconds page in a pagination or similar.

See also: Sqlpassthrough, PSEvalValue, PSEvalTuples

This page was edited more than 7 months ago on 06/04/2024. What links here