Decisions |
A decision is a programmatic construct you can use to perform a test before you perform an action. If the test is passed, a Yes Action is executed; otherwise a No Action is executed. Another use of decisions is to start a method call script or batch job for each record in a set of records retrieved by a SQL statement. A decision can be used and reused, as applicable, by many objects. Reusability, is an important criterion to consider using a decision instead of direct scripting. Direct scripting, however, is easier to find and maintain because it is attached to the object itself. To maintain reusability of a decision, you should document each decision and its applicable object(s). You can define Decisions by choosing Define, Decisions from the Definer main menu. Once a Decision exists, you can call it from GUI objects, menu items, SQL Tasks, or from other decisions: ActionDecision(<decision_name>) The decision's Decision SQL defines the test to be passed, or the data to be retrieved. It takes the form of a SQL WHERE clause or a full SQL statement, and colons (:) can be used to refer to current on-screen column values: :SALARY > 20000
SELECT sum(sal) FROM emp WHERE deptno = :DEPTNO If the test is passed or records are retrieved, then the Yes Action method call script is executed. If more than one record is retrieved, then the Yes Action script is executed for each of those records. If the test is not passed or if no records are retrieved, the No Action method call script is executed. You can compose Yes Action and No Action scripts by opening the Object Activator as a stand-alone editor. Values retrieved by Decision SQL can be passed to Yes Action scripts by special placeholders. These placeholders take the form of colons followed by position numbers (:1, :2). Please refer to Decisions Examples for details. Decisions can call each other. However, be careful to prevent writing an infinite loop. Any circular chain should include at least one decision whose condition will eventually change as a result of the activated actions and thereby break the circle. The Client Path attribute of decisions is obsolete and supported for backward compatibility only. Related Topics Decisions Example 1: Condition Decisions Example 2: Data Retrieval and Variable Message Decisions Example 3: Starting Multiple Batch Jobs |