The RETURN statement ends processing. What happens next depends on the programming context in which the RETURN statement is issued.
When used in a function, the RETURN statement stops processing of that function and returns control to the calling expression. The expression (which must be present) is evaluated and acts as the return value of the function. It is an error for a function to return by running off the list of statements. The data type of the returned value must be the same as that in the function's declaration.
When used in a procedure, the RETURN statement stops processing of that procedure and returns control to the calling CALL statement. A RETURN statement used within a procedure must not have an expression.
When used in a Filter, Compute, or Database node's mainline code, the RETURN statement stops processing of the node's ESQL and passes control to the next node. In these cases, if expression is present, it must evaluate to a BOOLEAN value. If expression is not present, a Filter node assumes a value of UNKNOWN and propagates to its unknown terminal; Compute and Database nodes propagate to their out terminals.
Return value | Result | |
Compute node: | ||
RETURN | TRUE | Propagate message to out terminal. |
FALSE | Do not propagate. | |
UNKNOWN | Do not propagate. | |
RETURN; | Propagate message to out terminal. | |
Filter node: | ||
RETURN | TRUE | Propagate message to true terminal. |
FALSE | Propagate message to false terminal. | |
UNKNOWN | Propagate message to unknown terminal. | |
RETURN; | Propagate message to unknown terminal. | |
Database node: | ||
RETURN | TRUE | Propagate message to out terminal. |
FALSE | Do not propagate. | |
UNKNOWN | Do not propagate. | |
RETURN; | Propagate message to out terminal. |
-- Declare variables -- DECLARE a INT; DECLARE PriceTotal FLOAT; DECLARE NumItems INT; -- Initialize values -- SET a = 1; SET NumItems = 0; SET PriceTotal = 0.0; -- Calculate value of order, however if this is a bulk purchase, the -- -- order will need to be handled differently (discount given) so return TRUE -- -- or FALSE depending on the size of the order -- WHILE a <= CARDINALITY(Invoice.Purchases.Item[a] DO SET NumItems = NumItems + Invoice.Purchases.Item[a].Quantity; SET PriceTotal = PriceTotal + Invoice.Purchases.Item[a].UnitPrice; SET a = a + 1; END; RETURN PriceTotal/NumItems > 42;If the average price of items is greater than 42, TRUE is returned; otherwise FALSE is returned. Thus, a Filter node could route messages describing expensive items down a different path from messages describing inexpensive items.
See PROPAGATE statement for an example of RETURN FALSE to prevent the implicit propagate at the end of processing in a Compute node.
Notices |
Trademarks |
Downloads |
Library |
Support |
Feedback
![]() ![]() |
ak05130_ |