Errors While Updating Table with Triggers

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jigesh
Posts: 16
Joined: Tue 11 Oct 2005 21:04

Errors While Updating Table with Triggers

Post by jigesh » Fri 22 Oct 2010 15:31

Hi,

After I upgraded my SDAC from 3.70.2.28 to 5.00.0.1, Whenever I edit a record in a table which also has an Update Trigger, the application is generating an error "Update failed. Found 4 records." This error occurs when the Update Trigger of the table kicks in. In the update trigger I am updating all the records that meet a certain criteria in a different table.

Here is the Update Trigger:

CREATE TRIGGER UpdateSheetAlloc ON dbo.TicketWorksheet_T
FOR UPDATE
AS

DECLARE @sig int
DECLARE @holo int
DECLARE @foil int
DECLARE @FO int
DECLARE @BO int
DECLARE @sQty int
DECLARE @fQty int
DECLARE @hQty int
DECLARE @FOQty int
DECLARE @BOQty int

DECLARE @F int
DECLARE @B int
DECLARE @M int
DECLARE @dF int
DECLARE @dB int
DECLARE @dM int

DECLARE @FShts int
DECLARE @BShts int
DECLARE @MShts int
DECLARE @dFShts int
DECLARE @dBShts int
DECLARE @dMShts int

DECLARE @WID numeric
DECLARE @dWID numeric
DECLARE @dJNo float
DECLARE @JNo float
DECLARE @TackYN char(1)
DECLARE @ItmDesc varchar(20)
DECLARE @prnLocID int
DECLARE @prnLocAbr char(5)
DECLARE @StkAvail char(1)
DECLARE @DateStkAvail DateTime

SELECT @prnLocID = o.PrintLoc
FROM inserted ins
JOIN Orders_T o ON
ins.JobNo = o.JobNo

SELECT @prnLocAbr = p.LocAbr
FROM PrintLocation_T p
WHERE p.PrintLocID = @prnLocID

SELECT @TackYN = o.TackYN
FROM inserted ins
JOIN Orders_T o ON
ins.JobNo = o.JobNo



SELECT @WID = ins.WOID,
@JNo = ins.JobNo,
@F = ins.FrontCore,
@B = ins.BackCore,
@M = ins.MiddleCore,
@FShts = ins.TotFShts,
@BShts = ins.TotBShts,
@MShts = ins.TotMShts,
@sig = ins.SigID,
@holo = ins.HoloID,
@foil = ins.FoilID,
@FO = ins.FOverLayID,
@BO = ins.BOverLayID,
@sQty = ins.SigQty,
@hQty = ins.HoloQty,
@fQty = ins.FoilQty,
@FOQty = ins.FOverLayQty,
@BOQty = ins.BOverLayQty,
@StkAvail = ins.StKAvailYN,
@DateStkAvail = ins.DateStkAvail
FROM inserted ins

SELECT @dWID = del.WOID,
@dJNo = del.JobNo,
@dF = del.FrontCore,
@dB = del.BackCore,
@dM = del.MiddleCore,
@dFShts = del.TotFShts,
@dBShts = del.TotBShts,
@dMShts = del.TotMShts
FROM deleted del


SELECT @ItmDesc = MatlCostCntr.ItemID
FROM MatlCostCntr
WHERE MatlCostCntr.MCCN = @F

/* Problems are occuring here */

UPDATE InPrep_T
SET StockID = @F,
ItemID = @ItmDesc
WHERE JobN = @JNo AND (EquipID >= 1501 AND EquipID <= 2004)


But if I check the data in the table everything is getting updated correctly.
But the error shows up in the application.

Before the upgrade to the latest SDAC version I did not have any errors. I don't know what the problem is, but I could like to have my program behave as it did when I was using SDAC 3.70.2.28.

Otherwise I have to uninstall SDAC 5.00.0.1 and reinstall SDAC 3.78.2.28. I don't even know how many more of my application modules may have errors using the new SDAC version.

I really need your help in resolving this issue. Do I have to make any global settings that will rectify my problems.

Please help

From

Jigesh

AndreyZ

Post by AndreyZ » Mon 25 Oct 2010 10:37

Hello,

Try using the __UseUpdateOptimization global variable. However in some cases it cannot help because of triggers that snap into action both before and after modification. In this case you should set the TMSTable.Options.StrictUpdate property to False.

Post Reply