Problema con un trigger de actualizacion
Realice un Trigger pero creo que estoy cayendo en recursividad, pues el campo dispara el suceso, lo nesecito cambiar dentro del trigger.
create trigger valocclienteup2
on soheader
for update
as
declare @vccustid as char(15)
declare @vcordcom as char(25)
declare @vccantoc as int
if update(adminhold)
begin
set @vccustid = (select custid
from inserted)
set @vcordcom = (select custordnbr
from inserted)
set @vccantoc = (select count(custordnbr)
from soheader
where custid = @vccustid
and custordnbr = @vcordcom)
if @vccantoc = 1
update soheader
set adminhold = 0
from soheader inner join inserted on soheader.ordnbr = inserted.ordnbr
else
update soheader
set adminhold = 1
from soheader inner join inserted on soheader.ordnbr = inserted.ordnbr
end
Es posible realisar esta operacion?
Que alternativa podria seguir?
create trigger valocclienteup2
on soheader
for update
as
declare @vccustid as char(15)
declare @vcordcom as char(25)
declare @vccantoc as int
if update(adminhold)
begin
set @vccustid = (select custid
from inserted)
set @vcordcom = (select custordnbr
from inserted)
set @vccantoc = (select count(custordnbr)
from soheader
where custid = @vccustid
and custordnbr = @vcordcom)
if @vccantoc = 1
update soheader
set adminhold = 0
from soheader inner join inserted on soheader.ordnbr = inserted.ordnbr
else
update soheader
set adminhold = 1
from soheader inner join inserted on soheader.ordnbr = inserted.ordnbr
end
Es posible realisar esta operacion?
Que alternativa podria seguir?
1 Respuesta
Respuesta de rume83
1