Presentation is loading. Please wait.

Presentation is loading. Please wait.

7.5 Using Stored-Procedure and Triggers NAME MATRIC NUM GROUP Muhammad Azwan Bin Khairul Anwar2012918725CS2305A Muhammad Faiz Bin Badrol Shah2012375409CS2305B.

Similar presentations


Presentation on theme: "7.5 Using Stored-Procedure and Triggers NAME MATRIC NUM GROUP Muhammad Azwan Bin Khairul Anwar2012918725CS2305A Muhammad Faiz Bin Badrol Shah2012375409CS2305B."— Presentation transcript:

1 7.5 Using Stored-Procedure and Triggers NAME MATRIC NUM GROUP Muhammad Azwan Bin Khairul Anwar2012918725CS2305A Muhammad Faiz Bin Badrol Shah2012375409CS2305B Nurul Hasana Binti Zainal Abidin2012372491CS2305B Wan Aizuddin Bin Wan Azizan2012945777CS2305B

2 Stored Procedure A set of Structured Query Language (SQL) statements with an assigned name that's stored in the database in compiled form so that it can be shared by a number of programs. The use of stored procedures :  can be helpful in controlling access to data (end-users may enter or change data but do not write procedures)  preserving data integrity (information is entered in a consistent manner)  improving productivity (statements in a stored procedure only need to be written one time)

3 Benefits of Stored Program Stored procedure is helpful in enhancing the security since we can grant permission to the user for executing the Stored procedure instead of giving the permission on the tables used in the Stored procedure. It helps in reusability of the sql code because it can be used by multiple users and by multiple client since we needs to just call the stored procedure instead of writing the same sql statement every time. It helps in reduces the development time. useful to use the database for storing the business logic in the form of stored procedure since it make it secure and if any change is needed in the business logic then we may only need to make changes in the stored procedure and not in the files contained on the web server.

4 In a DBMS, a trigger is a SQL procedure that initiates an action (i.e., fires an action) when an event (INSERT, DELETE or UPDATE) occurs. Since triggers are event- driven specialized procedures, they are stored in and managed by the DBMS. A trigger cannot be called or executed; the DBMS automatically fires the trigger as a result of a data modification to the associated table. Triggers The use of triggers:  to maintain the referential integrity of data (by changing the data in a systematic)

5 Benefits of Triggers Triggers can be used as an alternative method for implementing referential integrity constraints. By using triggers, business rules and transactions are easy to store in database and can be used consistently even if there are future updates to the database. When a change happens in a database a trigger can adjust the change to the entire database.

6 Stored Procedure Triggers  can execute whenever we want with the help of the execute command  can only be executed whenever an event (insert, delete, and update) is fired on the table  can return values  cannot return a value  can use transaction statements like begin transaction, commit transaction, and rollback  can't use transaction statements  can call a stored procedure from inside another stored procedure  can't directly call another trigger within a trigger

7 Example of Application Stored procedure and triggers Web Application :  Security : Many database engines can grant permission to run a stored procedure without granting general permissions to the tables. Also, using triggers to write history records has the big advantage that even if the application is compromised, the attackers won't be able disable the logging.  Consistency between multiple applications : When you have complex query that needs to be done consistently by different clients, you can put it in stored procedure.  Shielding multiple clients from changes in the schema. If you have database accessed by multiple clients, than if you need to change the schema for one of them, stored procedures and views can hide change from the others so you don't have to update them immediately.


Download ppt "7.5 Using Stored-Procedure and Triggers NAME MATRIC NUM GROUP Muhammad Azwan Bin Khairul Anwar2012918725CS2305A Muhammad Faiz Bin Badrol Shah2012375409CS2305B."

Similar presentations


Ads by Google