Kbase P33990: 4GL: database trigger does not create child record
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  7/28/2003 |
|
Status: Unverified
SYMPTOM(s):
4GL: database trigger does not create child record
Child record created in FIND trigger
FIND trigger on parent table
FOR EACH or QUERY joining parent and child table, using BY phrase to sort on child table
CAUSE:
Due to basic performance opimizations in the query engine, setting the BY phrase on the child record will cause the child table to be searched first.
At that time no child record exists, the join on the tables fails at that point and there will be no records fetched from the parent table.
Since no record is fetched from the parent table, the FIND trigger will not fire and the child record will not be created.
FIX:
At the very least, in a scenario such as this the sorting should take place on the parent table.
More likely, a different coding approach should be taken. Possibilities are:
- Using Nested FOR EACH loops / two separate, synchronized queries instead of a join.
- Creating the child record in a CREATE trigger on the parent table, thus ensuring it's always there.