-1
I need to create a stored procedure to update the salaries of employees who earn less than 1000 and give a 10% increase. Other employees (who earn over 1000) will have 15% reduction. I did the following:
DELIMITER $
CREATE PROCEDURE modificaSalario2()
BEGIN
update Funcionario set Salario=Salario*1.10 where Salario<1000;
update Funcionario set Salario=Salario-(Salario*0.15) where Salario>1000;
END $
DELIMITER ;
The problem is that there is possibility to give the increase of 10% and then give the discount of 15%. Ex: an employee who earns R$950 receives a 10% increase and receives R$1045. Soon after it will suffer a reduction of 15% and earn $ 888,25.
This case of yours would be best handled with a
case when
, not with two updates. This looks like a similar case to shoot coconuts with cannons– Jefferson Quesado
By the way, when you have row of appointments in a Procedure, they are executed sequentially. There are no mechanisms that make two queries "in parallel" in the same batch, be it Procedure or even a visual client that allows writing and executing queries
– Jefferson Quesado