FROM Statement
SYNTAX:
from_stmt = from_head when_clause BEGIN stmt { stmt } END ?;? .
The FROM statement declaration begins with a head that is equal to the head in the FROM clause in the MAP and COMPOSE declaration. The from head is followed by a WHEN clause that is equal to the WHEN clause in the MAP and COMPOSE declarations. The WHEN clause is followed by the keyword BEGIN followed by a sequence of one or more statements. The FROM statement declarations ends with the END keyword.
Logically the FROM statement creates an iteration for each entity type listed in the head of the FROM statement. All subtypes of the types that are specified with the optional keyword SUBTYPE, will be added to actual list of types to iterate over. The iterations are nested in the same order as the types are listed in the head of the FROM statement. This has the effect of executing the WHEN clause for every combination of entity instances corresponding to the entity types listed in the FROM statement header. The identifier in the extended entity references for these entity types are initialized appropriately for each iteration.
The FROM statement defines a scope for the identifier in the extended entity references listed in the FROM statement header, i.e. this identifier can be referenced from any construct within the actual FROM statement.
The FROM head may list entity types from the source as well as from the target schema. All EDMexpressX statements can be used within a FROM statement, hence FROM statements can be nested.
Optionally the FROM head in can contain the keyword ORDER_BY to specify that the instances of the actual type should be ordered in the iteration process according to the value of the attribute specified by the attribute_id. The keywords ASC or DESC can optionally be specified to select between ascending and descending order. If none of the keywords ASC or DESC are specified after the ORDER_BY keyword, then the order will be ascending.
The execution of the FROM statement can be escaped by means of the ESCAPE statement or the xpxEscapeScope function. It is also possible to terminate the execution of a specific iterator. See xpxTerminateXpxIterator.
Example:
FROM (c:source::Child, w:source::Woman)
WHEN (c IN w.children);
BEGIN
IF (c.sex = MALE) THEN
t.children ++ {target::Boy}c;
ELSE
t.children ++ {target::Girl}c;
END_IF;
. . .
END; -- end of FROM statement