Stored procedures

Suppose you need to execute a series of statements in MySQL, instead of sending all SQL statements every time, you can encapsulate all the statements in a single program and call it whenever required. A stored procedure is a set of SQL statements for which no return value is needed.

Apart from SQL statements, you can make use of variables to store results and do programmatical stuff inside a stored procedure. For example, you can write IF, CASE clauses, logical operations, and WHILE loops.

  • Stored functions and procedures are also referred to as stored routines.
  • For creating a stored procedure, you should have the CREATE ROUTINE privilege.
  • Stored functions will have a return value.
  • Stored procedures do not have a return ...

Get MySQL 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.