I want to create a procedure in which all types of possible errors can be handled using SIGNAL. Below is my stored procedure:
DROP PROCEDURE IF EXISTS `spItem`$$
CREATE PROCEDURE `spItem`(
IN p_itemname VARCHAR(50),
IN p_itemvalue smallint(6),
)
BEGIN
INSERT INTO item VALUES('',p_itemname,p_itemvalue);
END$$
How can we use the SIGNAL statement for each kind of error in the above stored procedure that checks for the following:
1. check for any error in the insert statement
2. check for duplicate item names
3. check for valid item values (as it should just accept numeric values).
What changes will be required in the above stored procedure to handle the above errors?