Hello everyone, there is such a task: create stored procedures on SELECT, INSERT / UPDATE and DELETE. There is a table (my_table) for these procedures with two columns ID and NAME. I can not understand how to request

select * from my_table; 

turn into a stored procedure. Only came to mind:

 CREATE PROCEDURE sel () begin select * from my_table; end // 

Please tell me what is wrong, and where to read about it? I will need these procedures in the server application (in java) that will call them. Do I need to foresee something in them, or are they simply called by name?

    1 answer 1

    Please tell me what is wrong

    Yes, everything is so. If DELIMITER is not to forget. Well, except for syntax rigor, you can put a semicolon after the END to put ... Plus a remark that, for a procedure from a single statement, the BEGIN-END block is not necessary ...

    Where to read about it?

    In the documentation, certainly. Stored Programs and Views .

    • And how can you add / change a row in a table in one procedure? Logically, it should compare the value with those in the table and add (if not), edit (if yes)? - Hev
    • one
      This does not require a procedure, a sufficiently unique index and INSERT. ON DUPLICATE KEY UPDATE (or REPLACE). - Akina