Hi!
I have a problem. When I change values of a record in the table, I need to update some other child records in the same table. And I want to make it work using trigger. But nesting error is raised on trigger execution. I use the following code:
FUNCTION Update_Child_Fields
IF myTable.Type = 1 && Type = 1 - Parent, Type = 2 - Child
lcParentID = ALLTRIM(myTable.Key)
lcOwnerID = ALLTRIM(myTable.OwnerID)
lcAliasName = SYS(2015)
USE myTable AGAIN IN 0 ALIAS (lcAliasName)
SELECT (lcAliasName)
Replace Parent_OwnerID WITH lcOwnerID;
FOR ALLTRIM(Parent) == lcParentID
IN (lcAliasName)
USE IN (lcAliasName)
ENDIF
ENDFUNC
I call this function in myTable's Update trigger. I have no idea why it doesn't work and how to make it work correctly. Need your help.
P.S. Now I removed all links to MyTable (i.e. Key instead of myTable.Key, etc.). Now it says: "Illegal recursion in rule evaluation". As far as I could understand, trigger can't be fired within itself.
But I need to make it work. How?
Eugene