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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Action type with triggers? 1

Status
Not open for further replies.

russland

Programmer
Jan 9, 2003
315
CH
Hi all,

I want to save the DML action on this table to a Log table. Do you know how I can determine what DML-Action was triggered? INSERT, UPDATE OR DELETE?

Any hint is welcome, thanks.


CREATE TRIGGER ListenToEventsOnUsers on A_Users
AFTER INSERT, UPDATE, DELETE
AS
INSERT A_Log
(DBUser, ActionType, LoggedObject)
VALUES (CURRENT_USER, ACTIONTYPE , 'A_Users')
 
Why not create a trigger for each action ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
best and correct way would be to create a trigger for each action.

But the following may help you. untested.

select @old_count = select count(*) from deleted
select @new_count = select count(*) from inserted

If doing a insert @old_count should be zero
If doing a delete @new_count should be zero
If doing a update both counts should not be zero


As I said it is completely untested and it may not be the way it works. try it.



Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top