Home Stored Procedures Delete Delete Stored Procedure using single input variable

Delete Stored Procedure using single input variable

Procedure Name:
team_del

Procedure type:
Delete

Input variables:
One

Output:
None

Uses function:
None

The purpose of this stored procedure is to demonstrate using a simple IF statement before deleting a row from a table.

Tables:

team table

Stored Procedure

DELIMITER $$
DROP PROCEDURE IF EXISTS `team_del`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `team_del`(IN tm_id INT)
BEGIN
/*****************************************
Spoc Name: team_set
Date created: 07/27/2009
Author: tcblazek
Description: Delete a single row in the team table
Input variables: The team table primary key team_id
Output: None
*****************************************/
IF tm_id > 0
THEN
DELETE FROM team
WHERE team_id = tm_id;
END IF;
END $$
DELIMITER ;

Call Stored Procedure

Set up test data first:
call team_set(0, 3, 1, 'XYZ', 'Test Team', 'Test Team to test a delete', '2009-07-27 07:47:37', 'Admin');
call team_del(9);

Result Set

Row physically deleted

Sample Data Used

Team Table
team data
Who's Online
We have 56 guests online