I want to make a query with STORED PROCEDURES where I can eliminate with a conditioner

0

Eliminate an employee permanently. For this will have to verify that said employee is not being referenced in tables DEPARTAMENTO , TRABAJA_EN and DEPENDIENTE . In the event that yes there is a reference to send an error message indicating that the employee with the DNI XXXXXXXXX is being referenced in the table YYYYYYYYY.

I think you can do a if along with inner join but I do not know how to structure it correctly so that it does not execute an error.

create procedure pa_empleado_eliminar

@Nomb VARCHAR,
@Ape1 VARCHAR,
@Ape2 VARCHAR,
@Dni int,
@FechaNac DATE,
@Direccion VARCHAR,
@Sexo CHAR(1),
@Sueldo MONEY,
@SuperDni CHAR(9),
@Dno INT
as
delete from Nombre,Apellido1.empleado,Apellido2.empleado,Dni.empleado,FechaNac.empleado,Direccion.empleado,Sexo.empleado,Sueldo.empleado,SuperDni.empleado,Dno.empleado 
    from EMPLEADO 
    if (@Dni=dni.empleado and dni.director)
    inner join DEPARTAMENTO on Dni=DniDirector 
    inner join TRABAJA_EN on dni=DniEmpleado 
    inner join DEPENDIENTE on
    
asked by kenia 18.07.2018 в 05:35
source

0 answers