PL stored programs include stored procedures, stored functions, and triggers.
PL storage objects include the following types:
Stored procedure: Created using the
CREATE PROCEDUREstatement and invoked with theCALLstatement. A stored procedure does not return a value, but can have output parameters and can generate result sets to return to client programs.Stored functions: These objects are created using the
CREATE FUNCTIONstatement and are used similarly to built-in functions. You can call stored functions within expressions, and they return a value during expression evaluation.Trigger: This object is created using the
CREATE TRIGGERstatement and associated with a table. Operations such as insert or update on the table can activate the trigger.
Among them, stored procedures and functions are called stored routines. Stored routines and triggers are collectively referred to as stored programs.
Each stored procedure contains a body consisting of multiple SQL statements, which can be separated by semicolons (;). The body of a stored procedure begins with the BEGIN keyword and ends with the END; keyword.