当前位置:网站首页>PowerDesigner tip 2 trigger template

PowerDesigner tip 2 trigger template

2022-06-22 09:49:00 51CTO

Define a trigger template , This template can be used by all tables , If you want to modify the trigger , Just modify the trigger template .



[size=x-large][color=darkred] One 、 Define trigger templates [/color][/size]



1、 Add trigger template



[img]http://dl.iteye.com/upload/attachment/0072/8841/73d67afd-dacd-3ff0-8962-38503a587b58.png[/img]



2、 List of existing trigger templates



[img]http://dl.iteye.com/upload/attachment/0072/8843/2a2de56b-50a1-303a-ac18-227b03c223de.png[/img]



3、 Create a trigger template :



[img]http://dl.iteye.com/upload/attachment/0072/8845/d1d26db1-86bb-3133-b6cc-d40b2b57e0a2.png[/img]



[img]http://dl.iteye.com/upload/attachment/0072/8847/77e1c0c8-f0e9-3e42-8f5b-449cd0a3f365.png[/img]



4、 Authoring template name :



[img]http://dl.iteye.com/upload/attachment/0072/8849/6c3bedb4-02de-3291-9aa0-d62240dc91e5.png[/img]



5、 Write trigger statement :



[img]http://dl.iteye.com/upload/attachment/0072/8851/3ed24ba1-a2ed-3abb-8e1e-72200b59c88e.png[/img]



Here's how db2、mysql Trigger statement of :


db2:


CREATE TRIGGER TRG_%TABLE%_UPDATE_TIME


before


UPDATE


ON %TABLE% REFERENCING NEW AS newrow FOR EACH ROW MODE db2sql


SET


newrow.UPDATE_TIME = CURRENT TIMESTAMP



mysql:


create trigger %TRIGGER%


before


update


on %TABLE% for each row


SET NEW.UPDATE_TIME = CURRENT_TIMESTAMP




[size=x-large][color=darkred] Two 、 User table Through the trigger template Add trigger :[/color][/size]



[img]http://dl.iteye.com/upload/attachment/0072/8853/9b32970f-2949-36ac-b27e-834b812ab8e6.png[/img]



[img]http://dl.iteye.com/upload/attachment/0072/8855/a12755d2-e98a-3921-82a5-f1947b45bde0.png[/img]



[img]http://dl.iteye.com/upload/attachment/0072/8857/592a3026-be12-3a14-ad96-798fa830bbbb.png[/img]



choice Definition, And select the template we have defined :



[img]http://dl.iteye.com/upload/attachment/0072/8859/7936712e-34b9-3844-8358-3f59789dab00.png[/img]



[img]http://dl.iteye.com/upload/attachment/0072/8861/b90b5da0-b36c-392b-af6d-b9b152ecedb9.png[/img]


原网站

版权声明
本文为[51CTO]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206220932339830.html