SQLIntermediate#procedures

What is a stored procedure and how does it differ from a function?

A stored procedure is precompiled SQL invoked with CALL; it can perform DML, return multiple result sets and use OUT parameters. A function returns a value and can be used inside a SELECT expression.

Example
CREATE PROCEDURE raise_salary(IN emp INT, IN pct DECIMAL)
BEGIN
  UPDATE employees SET salary = salary * (1 + pct/100) WHERE id = emp;
END;
CALL raise_salary(5, 10);

Related Questions

1
SQLIntermediate#triggers

What is a trigger?

Open
2
SQLBeginner#aggregates#nulls

What are aggregate functions and how do NULLs affect them?

Open
3
SQLBeginner#nulls

How do you handle NULL values in SQL?

Open