Difference between Trigger and Stored Procedure?

Posted by  Sanat Shukla
 473  View(s)
Rate this:

  1. Re: Difference between Trigger and Stored Procedure?

    These are some difference between Trigger and Stored Procedure.

    A). Triggers fire implicitly while Stored Procedures fire explicitly.

    B). A stored procedure is a user-defined piece of code written in the local version of PL/SQL, which may return a value (making it a function) that is invoked by calling it explicitly.

    C). A trigger is a special type of stored procedure that runs automatically when these actions are performed like Insert, Update, Delete.

    D). We can do a lot of programming stuff in a stored procedure and execute again and again.

    E). We can create a procedure which takes the input process and give the output.

    F). We can handle the error through try catch.

    G). Stored procedures can return values but a trigger cannot return a value.

    H). The Trigger is called only automatically where the stored procedure can be called manually.

    I) With help of EXEC command, we can execute Store Procedure. But a trigger can only be executed whenever an event is fired its conditional.

    J). The Stored procedure can take input parameters, but we can't pass any type of parameters as input to a trigger.

    K). We can use transaction statements like begin a transaction, commit the transaction, and rollback inside a stored procedure but we can't use transaction statements inside a trigger because the trigger sends only warning messages.

    L). A stored procedure can call from the front end (.asp files, .aspx files, .ascx files, etc.) But we can't call a trigger from these files.