Stored Procedure with if

2

I have a table with the name, id, and salary fields.

I need a procedure that changes the employee's salary, if it receives one, it should raise the salary by 300 reais, in case another amount decreases the salary by 500 reais.

Do you know how this can be done?

    
asked by anonymous 29.09.2017 / 01:01

1 answer

3

Imagine that the resolution is something along these lines:

DELIMITER $$

CREATE PROCEDURE AumentarSalario(IN quantidade INT, codigoFuncionario INT)
BEGIN
    IF quantidade = 1 THEN
            <update que aumenta salario em 300 usando o codigoFuncionario recebido>
    ELSE
            <update que aumenta salario em 500 usando o codigoFuncionario recebido>
    END IF
END $$
DELIMITER ;

I left space for the commands to be inserted because they did not have certainty of the bank structure and received few details.

    
29.09.2017 / 01:22