If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How to monitor events on only one table?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-29-04, 08:15
NNicole NNicole is offline
Registered User
 
Join Date: May 2003
Posts: 57
Question How to monitor events on only one table?

Hello all!

DB2 v8.1, AIX v5.2

I noticed that there is one user doing update on specific column in one table that he/she shouldn't do. I want to find him somehow.
I was thinking about creating event monitor for that one table and I've found out that is impossible. The only possible is monitoring all tables. I expect him to do that in one day and monitoring all tables for one day costs lots of memory. There is no person except me(dbadm) who should change that column so I'm really curious who is that. I was thinking about triger but I don't know how to connect user's update with table. Every user has it user_id.
I don't have idea what to do.

Please if you can advice me...
Thank you in advance

NNicole
Reply With Quote
  #2 (permalink)  
Old 10-29-04, 08:55
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
There are special registers: CURRENT CLIENT_USERID, CURRENT CLIENT_WRKSTNNAME, and CURRENT CLIENT_APPLNAME - that may help you to identify the user in the trigger code. More details can be found in the SQL reference.
Reply With Quote
  #3 (permalink)  
Old 10-29-04, 09:32
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Example of a trigger to 'log' the user id updating col i in table samp1 :

CREATE TRIGGER TRIG1 AFTER UPDATE OF I ON SAMP1 FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC
insert into taudit values(USER,CURRENT TIMESTAMP) ;
END
@

If you want to stop users from updating the column, then a trigger like this may help :

CREATE TRIGGER TRIG2 NO CASCADE BEFORE UPDATE OF I ON SAMP1 FOR EACH ROW MODE DB2SQL
WHEN (USER <> 'ME')
SIGNAL SQLSTATE '85002' SET MESSAGE_TEXT='UPDATE OF COLUMN NOT ALLOWED'
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #4 (permalink)  
Old 10-29-04, 17:14
NNicole NNicole is offline
Registered User
 
Join Date: May 2003
Posts: 57
Sathyaram_s, n_i

Thank you very much...
:-))
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On