MySQL Stored Procedure - DELETE - Example

Source code to create and add sql delete stored procedure to catalog

The following example is for creating a simple delete stored procedure. You can run it through an explicit call from a host language program.

DROP PROCEDURE IF EXISTS `sp_students_DELETE_byPK` 
GO

CREATE PROCEDURE sp_students_DELETE_byPK
     (
        IN  p_student_id  INT(11) 
     )
BEGIN 

    DELETE FROM students
    WHERE  student_id = p_student_id ; 

END 

GO

Executing the sql delete stored procedure

Execute sql delete stored procedure

To run the stored procedure you need to supply a values to the applicable variables.

/***
   IN    p_student_id  INT(11)
***/

CALL sp_students_DELETE_byPK
   (
        25  
   )
GO

 

Link to schema for Students table

 Collapse All    Expand All
Custom Search

MySQL Information and Resources