Я пытаюсь создать триггер, перед созданием я пытаюсь проверить его на выполнение кода внутри.Коды извлечения работают сами по себе, но триггер не работает.Вот код:
USE [PMIDB]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[BRK_ÇEKME_KAP_INSERTED]
ON [dbo].[ATMATERIALTRANS]
FOR INSERT
AS BEGIN
DECLARE @RDATE DATE
DECLARE @MAKİNE VARCHAR(10)
DECLARE @OKUTULAN_BARKOD VARCHAR(20)
DECLARE @MIKTAR INT
DECLARE @WC_ID INT
SELECT * FROM ATMATERIALTRANS
DECLARE CUR CURSOR
FOR
SELECT TDATE, WORKCENTERS.CODE, ATMATERIALS.BARCODE, ATMATERIALS.AMOUNT, WC_ID FROM INSERTED T1
LEFT JOIN ATCOMPOSITIONS ON ATCOMPOSITIONS.ID=T1.COMPID
LEFT JOIN WORKCENTERS ON WORKCENTERS.ID=T1.WC_ID
LEFT JOIN ATMATERIALS ON ATMATERIALS.ID=ATCOMPOSITIONS.MATERIALID
WHERE T1.COMPID IS NOT NULL AND WORKCENTERS.CODE LIKE 'DD%'
OPEN CUR
FETCH NEXT FROM CUR INTO @RDATE, @MAKİNE, @OKUTULAN_BARKOD,@MIKTAR, @WC_ID
WHILE @@FETCH_STATUS=0 BEGIN
INSERT INTO BURAK..ÇEKME_KAP (TARİH,MAKİNE,OKUTULAN_BARKOD,MİKTAR, HAMMADDE_GCKOD)
VALUES
(@RDATE,
@MAKİNE,
@OKUTULAN_BARKOD,
@MIKTAR, 'G')
UPDATE BURAK..MALKABUL_BARKOD SET BURAK..MALKABUL_BARKOD.KULLANILDI =1 WHERE BURAK..MALKABUL_BARKOD.BARKOD=@OKUTULAN_BARKOD
FETCH NEXT FROM CUR INTO @RDATE, @MAKİNE, @OKUTULAN_BARKOD,@MIKTAR, @WC_ID
END
CLOSE CUR
DEALLOCATE CUR
END