我有一个与表相关联的触发器:
ALTER TRIGGER [dbo].[FECR_TRIMPRIME_RETENCIONES] ON some_table
定义如下:
ALTER TRIGGER [dbo].[FECR_TRIMPRIME_RETENCIONES] ON FECR_TRETENCIONES_IC
FOR UPDATE AS
IF UPDATE (RET_PRINT)
BEGIN
DECLARE @statusOld varchar, @status varchar,
@id int, @folioInt varchar(80),
@cveRet varchar(5),@cmd varchar(8000), @args varchar(8000)
SELECT @status = ISNULL(RET_PRINT,'NULL'),
@id = ISNULL(RET_ID,0),
@folioInt = ISNULL(RET_FOLIO_INT,'NULL'),
@cveRet = ISNULL(RET_CVE_RETENC,'NULL')
FROM inserted
PRINT @id
PRINT @folioInt
PRINT @cveRet
IF (@status = '' OR @status = 'NULL')
BEGIN
PRINT 'No se puede generar la retencion, no es un estado válido.'
END
SELECT @statusOld = RET_PRINT
FROM Deleted
IF(@statusOld = 'N')
BEGIN
IF(@status = 'S')
BEGIN
PRINT 'IMPRIME'
SET @args = '"'+CAST(@id AS VARCHAR(50))+'" "'+@cveRet+'" "'+@folioInt+'"'
--PRINT @args
SET @cmd = 'C:\ICCR\GRCR.exe '+@args
select @cmd
--PRINT @cmd
EXEC master..xp_cmdshell @cmd
END
END
ELSE
BEGIN
PRINT 'La retencion ya fue impresa.'
END
END
当我进行更新时,进程永远不会结束,我必须手动停止SQL Server服务。
我的日志文件打印了这一行:
当前命令发生严重错误。结果,如果有的话, 应该被丢弃。