Generation of the data flow in SQL access mode
Note: When the logical entity has a default logical server, the instructions related to the entity will automatically be assigned to the logical server.
In the example below, <S1> is the default logical server of ENTITY1, and <S2> is the default logical server of ENTITY2.
Typical structure
* For the window BEGIN_STD_DFL INSERT_STD <S1> CHAIN_SQL ENTITY1 *COND(E1_FIELD1= :E1_VAR_HOST1 AND .....) <S1> SQL_RET_CODE = *SQLCODE <S1> <S1> INSERT_STD ENTITY1 <S1> <S1> IF SQL_RET_CODE = 0 <S1> UPD_SQL ENTITY1 *ALL *COND(E1_FIELD1 = :E1_VAR_HOST1 AND .....) <S1> ELSE <S1> IF SQL_RET_CODE = 100 <S1> CREATE_SQL ENTITY1 <S1> END <S1> END END_STD_DFL * For a list BEGIN_STD_DFL READ_LST <window.object:list_prop> *MODIF INSERT_STD <S2> CHAIN_SQL ENTITY2 *COND(E2_FIELD1 = :E2_VAR_HOST1 AND .....) <S2> SQL_RET_CODE = *SQLCODE <S2> <S2> INSERT_STD ENTITY2 <S2> <S2> IF SQL_RET_CODE = 0 <S2> UPD_SQL ENTITY2 *ALL *COND(E2_FIELD1 = :E2_VAR_HOST1 AND .....) <S2> ELSE <S2> IF SQL_RET_CODE = 100 <S2> CREATE_SQL ENTITY2 <S2> END <S2> END END_READ_LST END_STD_DFL |
The conditions for the CHAIN_SQL and UPD_SQL correspond to equality tests, according to the following rule:
1. For a main entity of a load:
If the entity has a key, the test will affect each of the fields which constitute the key;
If it does not have a key, the test will affect the whole key of the first access whose path corresponds to the accesses specified;
Otherwise, the test will affect only the fields constituting the access path specified.
2. For any other entity:
If the accesses specified correspond to the entity's key, the test will affect the fields corresponding to the partial key of the entity;
Otherwise, if the accesses specified correspond to an entity's access, the test affects the fields corresponding to the partial key of the first access;
Otherwise, the test affects only the fields which constitute the access path specified.
As regards the host variables of the SQL condition, those taken into account are:
The first Input/Output (or Output if it is the list update) screen field whose origin is the logical property defined in the entity's access.
The first screen field whose original logical entity is different from the entity processed, but has the same original conceptual property.
The field of the entity which constitutes the access.
Click below for further information about: