IF (EXISTS(Select * from sys.systrigger where LCase(trigger_name) = LCase('TrigUpdateProArticles'))) THEN Drop trigger TrigUpdateProArticles END IF GO create trigger //Tozi skript e opravia problemite s Proformite. TrigUpdateProArticles after insert order 2 on DBA.Articles referencing new as new_art for each row begin declare @CancelInvNo integer; select CancelInvoiceNo into @CancelInvNo from Invoices where InvoiceNo = new_art.InvoiceNo; if(@CancelInvNo = 0) then if new_art.RegNo <> 0 then message 'new_art.RegNo=' || cast(new_art.RegNo as integer) type info to console; message 'new_art.ArticleNo' || cast(new_art.ArticleNo as integer) type info to console; update ProArticles set ArticleNo = (-1)*ArticleNo where RegNo = new_art.RegNo and ArticleNo = new_art.ArticleNo end if; if new_art.CreditNo <> 0 then update ProArticles set ArticleNo = (-1)*ArticleNo where CreditNo = new_art.CreditNo and ArticleNo = new_art.ArticleNo end if else if new_art.RegNo <> 0 then update ProArticles set ArticleNo = ABS(ArticleNo) where RegNo = new_art.RegNo and abs(ArticleNo) = new_art.ArticleNo end if; if new_art.CreditNo <> 0 then update ProArticles set ArticleNo = ABS(ArticleNo) where CreditNo = new_art.CreditNo and abs(ArticleNo) = new_art.ArticleNo end if end if end //v [14.11.2002] - else na if(@CancelInvNo=0) then