I want to make a trigger
that as soon as I make a dismissal to the rest of the employees I raise the salary by 20%, but I do not know how to operate directly with the cursor explícito
in this trigger
, since the query would give me back several values.
CREATE TRIGGER despemp
ON Empleado
FOR delete
AS
BEGIN
IF exists (select e# from deleted where (e# = (select e# from Empleado)))
BEGIN
DECLARE @salariomas float = 0.2*(select salario from Empleado) + (select salario from Empleado);
BEGIN TRY
update Empleado set salario = @salariomas;
END TRY
BEGIN CATCH
print 'No se ha podido realizar la inserción'
END CATCH
END
END