Database Triggers and Actions - Database Condition Trigger and Action
This section discusses the Flux trigger and action that are used to check the value of a specific item (or items) in the database.
The information below applies to all the database condition triggers and actions. For more specific information on a particular trigger or action, see the section for that item.
Condition Syntax for Database Condition Action and Trigger
This section describes the syntax for conditions. An SQL query returns a result as a set of zero or more rows. If the query returns zero rows, the Database Condition Action’s result will be negative, indicating that its condition was not met.
If the query returns one or more rows, only the first row is evaluated. Consequently, you must formulate your database query so that the relevant information is returned in the first row.
In that first row, there are several columns. The first column is number 1, the second column is number 2, and so on. To access column 1, use the following syntax.
COLUMN(1)
In general, refer to column N as COLUMN(N), where the N argument is a number greater than or equal to one.
You can use non-negative numbers. You can use some of the usual SQL relational and boolean operators: <, <=, =, <>, >=, >, AND, OR, NOT
Some examples include:
COLUMN(1) > 500
COLUMN(1) < 1000 AND COLUMN(2) > 5000
COLUMN(1) = 123
COLUMN(1) = 50 OR COLUMN(1) = 100
NOT COLUMN(1) = 50 OR COLUMN(1) = 100
NOT COLUMN(2) < 250
You may not use parentheses. These operators are evaluated from right to left. For example, in the exception condition NOT COLUMN(1) = 50 OR COLUMN(1) = 100, COLUMN(1) = 100 is evaluated, then COLUMN(1) = 50 is evaluated, then the OR operator is evaluated, and finally the NOT operator is evaluated.
Results
The Database Condition Trigger and Action return their result in the flow context variable “result”. The result contains a boolean flag indicating whether the condition was satisfied. You can access the result from the following field:
Flow Context Variable | Field | Java Type | Description | Prescript / Postscript Example |
---|---|---|---|---|
RESULT | result | boolean | Indicates whether the database condition was satisfied. | boolean result = flowContext.get("RESULT").result; System.out.println("Condition Satisfied? " + result); |
Passing Results with a Runtime Data Map
You can use a Runtime Data Map to copy the result field into a new variable, (for future reference or to reuse the data later in the workflow).
To copy the result field, you can use a data map like: