Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSSql7 trigger not firing after Tquery.commitchanges

Status
Not open for further replies.

LucieLastic

Programmer
May 9, 2001
1,694
GB
hi all
I have an update trigger on one of my tables but this doesn't fire when I alter the table with a TQuery. The data does change in the table though. This TQuery is using cached updates but my trigger will be repeated for each row. I also tried it with Cachedupdates and still didn't fire.
The trigger fires perfectly if I edit the table in SQLExplorer.

Any help welcome.
ta
lou
p.s. here's the trigger :-
CREATE TRIGGER [TR_U_SERAUD] ON [Series]
FOR UPDATE
AS
DECLARE @vcErrorMessage varchar(255)
, @BeginTransCount int

SELECT @BeginTransCount = @@TRANCOUNT
BEGIN TRANSACTION

INSERT Series_audit
(mod_id
,modDT
,modType
,UserID
,Series_id
,Season_id
,On_Sale_Date
,Flight_Type_id
,Flight_Frequency_id
,Day_of_week_id
,Tos1,Tos2,Tos3,Tos4)
SELECT d.mod_id
,d.modDT
,'U'
,d.UserID
,d.Series_id
,d.Season_id
,d.On_Sale_Date
,d.Flight_Type_id
,d.Flight_Frequency_id
,d.Day_of_week_id
,d.Tos1, d.Tos2, d.Tos3, d.Tos4
FROM deleted d
JOIN inserted i ON i.Series_id = d.Series_id
WHERE IsNull( i.Mod_id, '') <> IsNull( d.Mod_id, '')

IF @@Error <> 0
BEGIN
SELECT @vcErrorMessage = &quot;Error: Unable to write Update audit record for Series.&quot;
GOTO error
END

error:

IF @vcErrorMessage IS NULL
BEGIN
IF @@TRANCOUNT > @BeginTransCount COMMIT TRANSACTION
END
ELSE
BEGIN
IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION
RAISERROR ( @vcErrorMessage, 16, 1)
END
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top