Dynamiite Dynamiite - 5 months ago 51
SQL Question

SQL Differences between stored procedure and triggers

I'm having trouble understanding the difference between a stored procedure and a trigger in sql.
If someone could be kind enough to explain it to me that would be great.

Thanks in advance


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.

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

IMHO stored procedures are to be avoided unless absolutely required.