Database trigger Issue in V11

Posted by thomas.rothlisberger on 17-Dec-2014 00:59

Hi I am currently implementing V11.2 from V102B and experienced the following different behavior. I have the following for each loop with a database trigger on the child table: for each parent no-lock, each child no-lock where child.id = parent.id: 'do something' end. A database trigger on the find event: TRIGGER PROCEDURE FOR FIND OF child. if child.type = "deleted" then return error. The trigger code should skip child records that have a type of 'deleted'. This loop works fine in V102B but in V11.2 it does not finish properly. It works for a while then it drops out of the procedure and does not reach the end of the for each loop to continue. If I use 2 for each loops, one for the parent and one for the child, that works correctly. Has anybody experienced the same behavior and has maybe a workaround. Thanks for any help.

Posted by James Palmer on 17-Dec-2014 02:51

My work-around would be to do away with the FIND trigger and handle the exceptions "properly".

All Replies

Posted by James Palmer on 17-Dec-2014 02:49

Reposting with formatting so I can read it. 

Hi I am currently implementing V11.2 from V102B and experienced the following different behavior. I have the following for each loop with a database trigger on the child table:

for each parent no-lock, 
  each child no-lock where child.id = parent.id: 
  'do something' 
end. 


A database trigger on the find event:

TRIGGER PROCEDURE FOR FIND OF child. 
if child.type = "deleted" then return error.


The trigger code should skip child records that have a type of 'deleted'. This loop works fine in V102B but in V11.2 it does not finish properly. It works for a while then it drops out of the procedure and does not reach the end of the for each loop to continue. If I use 2 for each loops, one for the parent and one for the child, that works correctly.

Has anybody experienced the same behavior and has maybe a workaround. Thanks for any help. - See more at: https://community.progress.com/community_groups/openedge_development/f/19/t/14989.aspx?Redirected=true#sthash.GUGhUMUz.dpuf

Posted by James Palmer on 17-Dec-2014 02:51

My work-around would be to do away with the FIND trigger and handle the exceptions "properly".

Posted by James Palmer on 17-Dec-2014 04:12

Just realised my repost with formatting sounded rude. Not meant that way, sorry. The formatting will have been lost by the community software. A bug I gather is being looked at.

Posted by Frank Meulblok on 17-Dec-2014 04:16

"If I use 2 for each loops, one for the parent and one for the child, that works correctly."

I'd recommend doing that if you're looking for a quick workaround as it should require only minimal code changes.

And then plan on phasing out the FIND triggers.

Posted by thomas.rothlisberger on 17-Dec-2014 16:48

Thank you for your help,  James

I was hoping for a quick fix in the trigger code but in the long run it is better to deal with it properly. I am most likely to add another line in the for each loop tor the child record to do what the trigger code is doing.

Posted by James Palmer on 17-Dec-2014 16:59

That's a good solution I think. DB Triggers can be really useful, but from experience FIND triggers are a nightmare, not least because it's not transparent in the slightest. You end up with stuff happening and it's impossible to track down why.

Posted by thomas.rothlisberger on 17-Dec-2014 17:05

I completely agree and I personally never liked the db trigger for that reason. At least when it is dealt with in the code, everybody knows what is happening.

This thread is closed