When multiple applications need to perform common database operations, stored procedures can be used. It is a set of sql statements stored on the server. It has a name, parameters and some sql statements.
Example:
CREATE OR REPLACE PROCEDURE sample (x VARCHAR) IS
"BEGIN "
"INSERT INTO sample_table VALUES(x); "
"END;";
A trigger is a set of code which is executed in response to some event.
E.g Update employee_perfomance table when a new task is inserted in task table. Here, the trigger is “update” and the event is “inserting a new row”.
Example:
CREATE TRIGGER reminder
ON titles
FOR INSERT, UPDATE
AS some_function (50009, 16, 10)