Parameters
Parameter | Data Type | Description |
---|---|---|
Entity | String | Entity name. If omitted, the current entity is used. |
Return Values
$occdel is set to
1
if an occurrence is removed by the remocc statement or the ^REM_OCC structure editor
function.
Value | Meaning |
---|---|
1 | Occurrence is marked for removal. |
0 | Occurrence is not marked for removal. |
"" | Entity does not exist or is included in the component structure. |
Use
Allowed only in the delete trigger of any component type.
Description
The $occdel function is useful because an occurrence may be deleted without the user explicitly deleting this particular occurrence. Consider a relationship with a cascading delete, in which ENTITY_A is the One Entity and ENTITY_B is the many entity. In the component structure, ENTITY_A is the Outer Entity and ENTITY_B is the inner entity.
If the first occurrence of ENTITY_B is removed,
and a store is performed, the delete trigger is activated
only in the first occurrence of ENTITY_B; in this trigger, $occdel returns
1
(occurrence will be removed).
Now consider the following situation. The first
occurrence of ENTITY_B is removed, the occurrence of ENTITY_A is removed, then a
store is performed. The delete trigger
for the occurrence of ENTITY_A is activated, and $occdel returns
1
, because this occurrence is deleted. The delete trigger for the first occurrence of ENTITY_B is also
activated, and $occdel returns 1
, because this occurrence is also
deleted.
For the other occurrences in ENTITY_B (that is,
those that have not been explicitly removed), the actions performed by Uniface are slightly
different. The delete trigger is activated for ENTITY_B
only once. The occurrence number (given by $curocc) is NULL, and
$occdel returns 0
, as these other occurrences have not been
explicitly deleted.
Therefore, when there is a cascading delete, the delete trigger of the inner entities will be activated once for each occurrence removed, then a final time for all other occurrences.