[Data Center reconstruction]-trigger operations for divorce firms and trigger Firms

Source: Internet
Author: User

[Data Center reconstruction]-trigger operations for divorce firms and trigger Firms

I recently learned about the trigger, but now I prefer the trigger as a special Stored Procedure (trigger: you can perform a series of operations on another table based on the actions on this table.) At this moment, I will share with you how the trigger operates the divorce office:

I. Operating vulnerabilities (disadvantages of triggers ):

When a couple have the idea of leaving, they will take the marriage certificate to find the trigger (divorce office; at this time, the trigger does not care if you are sure you want to divorce (whether or not this event should be triggered), as long as you give him the Marriage Certificate and give some reasons, he will handle the divorce formalities for you (the process of punishment after the conditions are met). As we all know, once the divorce formalities are handled, then the two will not receive legal protection in their marriages (once the trigger penalizes the event, the corresponding operations will be performed on the table ), this would be very dangerous (in reality, divorce firms are not like this here only for understanding the trigger ).

Therefore, you must go to the divorce office and think clearly (use the trigger with caution). If you do not have any thoughts, you will be impulsive and rush to the divorce office to complete the divorce procedure, it will inevitably regret for life (the excessive dependency on triggers will inevitably affect the database structure and increase the complexity of maintenance ).

Ii. Business Benefits (advantages of triggers ):

When people go to the divorce office to complete the divorce procedure, the next marriage to another person will receive legal protection (the trigger can better execute the change through cascading reference integrity constraints ); it is also a witness of the absence of two people. It focuses more on future planning (triggers can evaluate the status of tables before and after data modification and take countermeasures based on their differences ).

Iii. Business example (trigger example ):

The following is the trigger I wrote in the rebuild recharge line of the data center: With this trigger, I directly insert the ReCharge_Info table when writing code (the following business function: insert) A piece of data, no need to return and then execute the Update card table. Here we will Update it directly (the following Update card table: Update!

<Span style = "font-family: KaiTi_GB2312; font-size: 24px; "> -- ============================================ =========-- Author: <Ma Kang> -- Create date: <2015-5-1> -- Description: <recharge trigger> -- ====================================== =========== create TRIGGER [dbo]. [AddSum] -- create a trigger named AddSum ON [dbo]. [ReCharge_Info] -- trigger events occur on the Recharge_Info table for insert -- business function is to add new data asbegindeclare @ CardID char (10) -- two variables are declared: cardID, AddCashdeclare @ AddCash int select @ CardID = CardID, @ AddCash = convert (int, AddCash) from inserted -- forcibly convert the CardID and AddCash types in the recharge table and assign them to @ CardID and @ AddCashUpdate Card_Info set Cash = convert (int, Cash) + @ AddCash where @ CardID = CardID -- Update the balance end in the card table </span>
4. business gains (using triggers ):

Note that when updating the AddCash field in the card table, you need to know the type of the field. The trigger is created in the table before the trigger and is created using: Create, if you want to modify the trigger, use Alter.

Through continuous learning and summarization, we can be more solid in the future. Come on!

If there is any error in this article, please correct it!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.