[MySQL]: Stored procedure and statement selection

I am currently viewing stored procedures.

According to this article (page 8) in the dev section of mysql website ...

This is usually not normal. SELECT statements are stored procedures, this is for illustration. I decided that some procedure should just select from our table, so when you call the procedure, it will be obvious that it works.

Why is this?

Using stored procedures to simplify complex selection operators rather than "best practices"?

What are the specific situations where it is useful to use a stored procedure? Example?

+5
source share
2 answers

. . , SELECT , , SQL, , . , .

.

, , - . . , .

+3

, /, , , . "Encapsulation"

:

CREATE PROCEDURE select_table(IN @id INT)
BEGIN
  IF @id < O THEN
    -- ERROR!  do something here
  ELSEIF
    SELECT * from TABLE WHERE id = @id;
  END IF
END
+3

All Articles