DROP PROCEDURE IF EXISTS printIncomeLevel;
DELIMITER //
CREATE PROCEDURE printIncomeLevel (IN monthly_value INT)
BEGIN
DECLARE income_level varchar(20);
IF monthly_value <= 4000 THEN
SET income_level = 'Low Income';
ELSEIF monthly_value > 4000 AND monthly_value <= 7000 THEN
SET income_level = 'Avg Income';
ELSE
SET income_level = 'High Income';
END IF;
INSERT INTO log (description)
VALUES ('getIncomeLevel procedure was called');
SELECT income_level;
END;
After creating the procedure, we can call it using
CALL
keyword:
CALL printIncomeLevel(450)