Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread How to delete detail records through master before trigger
Fri, Apr 29 2011 8:03 AMPermanent Link

Jianfei Xu

I would like to force the delete detail records before delete master records.

What is the best way to do it. I tried use on before delete trigger something like this

EXECUTE IMMEDIATE 'DELETE FROM DetailTableName WHERE xMasterGUID=''+OLDROW.xGUID+'''

not working

Thanks,

Jianfei
Fri, Apr 29 2011 8:35 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Jianfei


I use the after delete trigger with the same code as you and it works fine. Try switching from before delete to after delete. I'd always prefer to use after delete just in case it doesn't delete after all.

Roy Lambert

Wed, May 4 2011 4:06 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Jianfei,

<< What is the best way to do it. I tried use on before delete trigger
something like this >>

What are you seeing - an error message or does it simply not work ?

--
Tim Young
Elevate Software
www.elevatesoft.com
Sat, May 7 2011 10:11 AMPermanent Link

Jianfei Xu

Just Do nothing.

I am using following Code, it works


CREATE TRIGGER DD_xDP_ProgressActivity AFTER DELETE ON xDP_ProgressActivity
BEGIN
DECLARE DD STATEMENT;
PREPARE DD FROM 'DELETE FROM xDP_ProgressActivity_File WHERE xFileGUID=?';
EXECUTE DD USING OLDROW.xGUID;
END

Thanks,
Image