1.

What are the differences between stored procedure and triggers in SQL?

Answer»

Stored procedures are small pieces of PL/SQL code that PERFORM a specific task. The USER can call stored procedures directly. It's similar to a program in that it can take some input as a PARAMETER, process it, and return values.

Trigger, on the other hand, is a stored process that executes automatically when certain events occur (eg update, insert, delete in a database). Triggers are similar to event handlers in that they operate in response to a specified event. Triggers are unable to accept input or return values.

TriggersStored procedures
A trigger is a stored PROCEDURE that executes automatically in response to certain events (such as updates, inserts, and deletions).Stored procedures are sections of PL/SQL code that perform a specified operation.
It has the ability to run automatically in response to events.It can be called by the user explicitly.
It is unable to accept input as a parameter.It has the ability to accept input as a parameter.
TRANSACTION statements aren't allowed inside a trigger.Within a stored procedure, we can use transaction statements like begin transaction, commit transaction, and rollback.
Triggers do not have the ability to return values.Values can be returned by stored procedures.


Discussion

No Comment Found