Está en la página 1de 2

Componentes del Paquete

Cdigo de Procedimiento Almacenado (Ejecucin del Paquete)


create procedure myprod

as
exec msdb.dbo.sp_start_job @job_name = 'Actividad'
Cdigo del Trigger

create trigger TriggerVenta


on DETALLE_VENTA
for Insert
as
BEGIN
declare @varCantidad smallint, @varPrecio money, @varID tinyint, @varIDP tinyint,
@varAlmacen smallint
select @varID = IDV, @varIDP = IDP
from inserted
select @varCantidad = cantidad
from DETALLE_VENTA
where IDV = @varID and IDP = @varIDP
select @varPrecio = Precio
from PRODUCTO
where IDP = @varIDP
select @varAlmacen = Almacen
from PRODUCTO
where IDP = @varIDP
update DETALLE_VENTA
set Subtotal = @varCantidad * @VarPrecio
where IDV = @varID and IDP = @varIDP
update PRODUCTO
set Almacen = @varAlmacen - @varCantidad
where IDP = @varIDP

DECLARE @var INT


SELECT @var = Almacen FROM PRODUCTO

IF @var <= 10 exec myprod

END

También podría gustarte