-- Create a procedure for deleting : Delete « Procedure Function « SQL / MySQL






-- Create a procedure for deleting

       


CREATE   TABLE MATCHES
        (MATCHNO        INTEGER      NOT NULL,
         TEAMNO         INTEGER      NOT NULL,
         EmployeeNO       INTEGER      NOT NULL,
         WON            SMALLINT     NOT NULL,
         LOST           SMALLINT     NOT NULL,
         PRIMARY KEY    (MATCHNO)            );

INSERT INTO MATCHES VALUES ( 1, 1,   6, 3, 1);
INSERT INTO MATCHES VALUES ( 2, 1,   6, 2, 3);
INSERT INTO MATCHES VALUES ( 3, 1,   6, 3, 0);
INSERT INTO MATCHES VALUES ( 4, 1,  44, 3, 2);
INSERT INTO MATCHES VALUES ( 5, 1,  83, 0, 3);

DELIMITER $$

CREATE PROCEDURE DELETE_MATCHES(IN P_EmployeeNO INTEGER)
BEGIN
   DELETE
   FROM   MATCHES
   WHERE  EmployeeNO = P_EmployeeNO;
END$$

DELIMITER ;

CALL DELETE_MATCHES (8);

drop table MATCHES;

   
    
    
    
    
    
    
  








Related examples in the same category

1.DELETE statement with a procedure variable