The following example shows the template code for the Relationship Override of the Parent-Delete RESTRICT trigger. The top section shows a portion of the template, the center section shows the expanded code of the same portion, and the bottom section shows the complete trigger template expanded for a SQL Server. The template code is for the relationship override on CUST_ORDER-ORDER_LINE relationship using the Parent-Delete RESTRICT trigger.
/* erwin Built-in %Datetime */ /* %Parent %VerbPhrase %Child ON PARENT Delete RESTRICT */ update %Parent set order_status = 'outstanding' from %Parent,deleted,%Child where /* %%JoinPKPK(%Parent,deleted) */ %JoinPKPK(%Parent,deleted) and /* %%JoinFKPK(%Child,deleted) */ %JoinFKPK(%Child,deleted) /* erwin Built-in Mon May 09 07:52:30 2007 */ /* CUST_ORDER contains ORDER_LINE ON PARENT Delete RESTRICT */ update CUST_ORDER set order_status = 'outstanding' from CUST_ORDER,deleted,ORDER_LINE where /* %JoinPKPK(CUST_ORDER,deleted) */ CUST_ORDER.order_id = deleted.order_id and /* %JoinFKPK(ORDER_LINE,deleted) */ ORDER_LINE.order_id = deleted.order_id create trigger tD_CUST_ORDER on CUST_ORDER for Delete as /* erwin Built-in Mon May 09 07:55:10 2007 */ /* Delete trigger on CUST_ORDER */ begin declare @errno int, @errmsg varchar(255) /* erwin Built-in Mon May 09 07:55:10 2007 */ /* CUST_ORDER contains ORDER_LINE ON PARENT Delete RESTRICT */ update CUST_ORDER set order_status = 'outstanding' from CUST_ORDER,deleted,ORDER_LINE where /* %JoinPKPK(CUST_ORDER,deleted) */ CUST_ORDER.order_id = deleted.order_id and /* %JoinFKPK(ORDER_LINE,deleted) */ ORDER_LINE.order_id = deleted.order_id /* erwin Built-in Mon May 09 07:55:10 2007 */ return error: raiserror @errno @errmsg rollback transaction end go
Copyright © 2017 erwin Inc.
All rights reserved.
|
|