Hard sql

MySQL simple stored procedure

Problem

Write a procedure to increase salary by percentage for an employee id.

Hints
  • DELIMITER //, IN parameters, UPDATE

Your practice code

Ready — edit the code above and click Run.

Solution

DELIMITER //
CREATE PROCEDURE bump_salary(IN emp_id INT, IN pct DECIMAL(5,2))
BEGIN
  UPDATE employees SET salary = salary * (1 + pct/100) WHERE id = emp_id;
END //
DELIMITER ;

Try solving on your own first, then reveal the official answer.

Explanation

MySQL procedures use DELIMITER change and BEGIN/END blocks.

Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details