WHEN Clause


SYNTAX:
 
when_clause = WHEN domain_rule ';' .
The WHEN clause in a MAP declaration defines the conditions under which the map body of the MAP declaration should be executed. The when clause consist of the keyword WHEN followed by one logical expression. This logical expression has the same specification as a domain rule in the EXPRESS language.
Conceptually, the WHEN clause in a MAP declaration is evaluated for every combination of instances specified in the FROM clause. For each combination that produces a value of TRUE for the expression in the WHEN clause, a map instance will implicitly be created before executing the map body, provided a map entity has been specified in the actual map head. If a map instance is implicitly created, it can be referred to throughout the actual MAP declaration by its corresponding extended_entity_ref_id.
Example:
(*
In the example mapping schema mapping_schema_example1, the WHEN clause has the following form:
*)
MAP t_e:target::targetEntity;
FROM (sa:source::sourceEntityA, sb:source::sourceEntityB,     sc:source::sourceEntityC)
WHEN ((sa.int_a1 = sb.complex_b1.int_a1)
  AND
  (NOT (sc.real_c1 > 10.0)));
BEGIN_MAP
 . . .
END_MAP;
 
The expression in the WHEN clause is evaluated once for each combination of source instances of types source::sourceEntityA, source::sourceEntityB, and source::sourceEntityC generated by the preceding FROM clause. For each combination of source instances for which the WHEN clause is evaluated to TRUE, a new map instance of type target::targetEntity is created. The value of this instance is assigned to the variable named t_e. Hence this current map instance can be referred to by the variable named t_e ,throughout the rest of the MAP declaration. In the same way, the variables sa, sb, and sc are variables whose current values are instances of type source::sourceEntityA, source::sourceEntityB, and source::sourceEntityC respectively.