0

hi
i would like to write a trigger for the basic operations on a table : insert, delete, update.

i know the basic syntax:

create trigger on 
                  tbl_MyReports
              for
                  insert,delete,update
as

my question is how can i know which rows changed ?
if i inserted or deleted or updated a row or many rows how can i know which row changed and how can i access the rows columns ?

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by urtrivedi
0

Triggers are generally of two types Statement level and row level.
Right now I dont remember syntax.

But if you want to create trigger at row level
You can access values using inserted cursor and deleted cursor.

if row is inserted new values can be accessed as
inserted.col1, inserted.col2...... etc

if row is update new values can be accessed as
inserted.col1, inserted.col2...... etc
and old values can be accessed as
deleted.col1, deleted.col2...... etc

if row is deleted deleted values can be accessed as
deleted.col1, deleted.col2...... etc

Please refer manual for details

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.