Difference between stored procedure and triggers in SQL

SQLSQLiteDatabase

Stored procedures are a pieces of the code in written in PL/SQL to do some specific task. Stored procedures can be invoked explicitly by the user. It's like a java program , it can take some input as a parameter then can do some processing and can return values.

On the other hand,  trigger is a stored procedure that runs automatically when various events happen (eg update, insert, delete). Triggers are more like an event handler they run at the specific event. Trigger can not take input and they can’t return values.

Sr. No.KeyTriggersStored procedures

1

Basic 

trigger is a stored procedure that runs automatically when various events happen (eg update, insert, delete)

Stored procedures are a pieces of the code in written in PL/SQL to do some specific task

2

        Running Methodology 

It can execute automatically based on the events 

It can be invoked explicitly by the user

3

Parameter 

It can not take input as parameter 

It can take input as a parameter 

4

Transaction statements

we can't use transaction statements inside a trigger

We can use transaction statements like begin transaction, commit transaction, and rollback inside a stored procedure

5

Return 

Triggers can not return values 

Stored procedures can return values 


raja
Published on 21-Jan-2020 14:28:29
Advertisements