473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

DB2 Trigger To Track Table Changes

Can anyone please provide some assistance with a trigger that I need to
develop. Here is the situation:

Our program updates depend on database updates. If a client receives
the program update and the database hasn't been updated then it's a
huge mess. No problem right? Just document the changes to the
database that you made and then send out a SQL script that will update
the database with the program update right?

Well, I don't trust anyone here to document anything, so I wanted to
automate the tracking of the changes made to the database. So, I want
to create a table that stores changes made to any part of the database
(create table, drop table, rename table, create column, drop column,
column reorder, change column data type/length/precision).

I am very new to triggers and do not know all I need to know about them
to create what I want so that's why I need someone's help.

(I do not know if DB2 tracks changes somewhere, only place I would know
where to look is on a INSERT,UPDATE,or DELETE from the SYSIBM.SYSTABLES
and SYSIBM.SYSCOLUMNS and SYSIBM.SYSCOLPROPERTIES and SYSIBM.SYSOPTIONS
and SYSIBM.SYSCONSTDEP)

What I need is a trigger that will work one of two ways, if a change
was made to the database then the trigger would either:

1) write a line of text to a txt file or xml file explaining the change
or
2) insert a record into a table that I create so that I can select from
it to view the changes.

Is there an easier way of doing this?

Thanks,
Keith Culpepper
McAleer Solutions

May 5 '06 #1
5 5597
Given that you do not expect these changes to occur many times a day then
the DB2 auditor might be what you need.
Do a db2audit -h and you'll find that you can audit for
OBJMAINT which tracks who, what, where, when DDL is run.
It will show the statement used and so on.

Mind, you should set the status to both so you could see who is successful
as well as who fails.

HTH, Pierre.
--
Pierre Saint-Jacques
SES Consultants Inc.
514-737-4515
<ke*************@gmail.com> a écrit dans le message de news:
11**********************@e56g2000cwe.googlegroups. com...
Can anyone please provide some assistance with a trigger that I need to
develop. Here is the situation:

Our program updates depend on database updates. If a client receives
the program update and the database hasn't been updated then it's a
huge mess. No problem right? Just document the changes to the
database that you made and then send out a SQL script that will update
the database with the program update right?

Well, I don't trust anyone here to document anything, so I wanted to
automate the tracking of the changes made to the database. So, I want
to create a table that stores changes made to any part of the database
(create table, drop table, rename table, create column, drop column,
column reorder, change column data type/length/precision).

I am very new to triggers and do not know all I need to know about them
to create what I want so that's why I need someone's help.

(I do not know if DB2 tracks changes somewhere, only place I would know
where to look is on a INSERT,UPDATE,or DELETE from the SYSIBM.SYSTABLES
and SYSIBM.SYSCOLUMNS and SYSIBM.SYSCOLPROPERTIES and SYSIBM.SYSOPTIONS
and SYSIBM.SYSCONSTDEP)

What I need is a trigger that will work one of two ways, if a change
was made to the database then the trigger would either:

1) write a line of text to a txt file or xml file explaining the change
or
2) insert a record into a table that I create so that I can select from
it to view the changes.

Is there an easier way of doing this?

Thanks,
Keith Culpepper
McAleer Solutions


May 5 '06 #2
Ok, I forgot to mention that I'm also new to DB2. MSSQL, different
story...

Ok, I guessed that I was supposed to run db2audit -h in the command
line processor but that didn't work. Not real sure how I'm supposed to
so what you recommended. Also, reason I would like to write the
changes either to an output file or to a table is so that we can
archive them and track them back to certain version numbers...

So, suggestions?

Thanks,
Keith

May 5 '06 #3
Ok, got the db2audit to work (sortof) but that's not quite what I want.
Before you extract the audit data to a .log file, it has to store that
information somewhere, right? Can I query this information instead of
extracting it? Or can I setup a trigger to query it?

Thanks,
Keith

May 5 '06 #4
ke*************@gmail.com wrote:
Ok, got the db2audit to work (sortof) but that's not quite what I want.
Before you extract the audit data to a .log file, it has to store that
information somewhere, right? Can I query this information instead of
extracting it? Or can I setup a trigger to query it?

No and No.
You don't appear to be doing this for auditing. Looks more like change
management from a development point of view.
Take a look at the Rational side of the IBM house. (Like Rational
Application Developer etc...)

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
May 5 '06 #5
Hi All,

I unload the syscolumns table daily

then do a delta compare (good old mf cobol) - and write the delta
changes to a db2 table

Bill
<ke*************@gmail.com> wrote in message
news:11**********************@e56g2000cwe.googlegr oups.com...
Can anyone please provide some assistance with a trigger that I need to
develop. Here is the situation:

Our program updates depend on database updates. If a client receives
the program update and the database hasn't been updated then it's a
huge mess. No problem right? Just document the changes to the
database that you made and then send out a SQL script that will update
the database with the program update right?

Well, I don't trust anyone here to document anything, so I wanted to
automate the tracking of the changes made to the database. So, I want
to create a table that stores changes made to any part of the database
(create table, drop table, rename table, create column, drop column,
column reorder, change column data type/length/precision).

I am very new to triggers and do not know all I need to know about them
to create what I want so that's why I need someone's help.

(I do not know if DB2 tracks changes somewhere, only place I would know
where to look is on a INSERT,UPDATE,or DELETE from the SYSIBM.SYSTABLES
and SYSIBM.SYSCOLUMNS and SYSIBM.SYSCOLPROPERTIES and SYSIBM.SYSOPTIONS
and SYSIBM.SYSCONSTDEP)

What I need is a trigger that will work one of two ways, if a change
was made to the database then the trigger would either:

1) write a line of text to a txt file or xml file explaining the change
or
2) insert a record into a table that I create so that I can select from
it to view the changes.

Is there an easier way of doing this?

Thanks,
Keith Culpepper
McAleer Solutions

Jun 28 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Trevor Fairchild | last post by:
I am trying to create a very minimal auditing system for a series of databases. I am in the process of writing Update triggers for 5 Tablse. I will write a trigger for each table-the trigger's...
10
by: Lauren Quantrell | last post by:
I have never written a trigger before and now am seeing the light. Is there a way to write a trigger so that if a user changes any column in a single row on one table then the trigger will write...
9
by: Martin | last post by:
Hello, I'm new with triggers and I can not find any good example on how to do the following: I have two tables WO and PM with the following fields: WO.WONUM, VARCHAR(10) WO.PMNUM,...
18
by: Bill Smith | last post by:
The initial row is inserted with the colPartNum column containing a valid LIKE pattern, such as (without the single quotes) 'AB%DE'. I want to update the column value with the results of a query...
9
by: steven | last post by:
Does anyone know how to do the following. I'm trying to mimic replication with triggers. I have 2 databases, each have these 2 tables. 1. USERS ID int NAME varchar(20)
9
by: Ots | last post by:
I'm using SQL 2000, which is integrated with a VB.NET 2003 app. I have an Audit trigger that logs changes to tables. I want to apply this trigger to many different tables. It's the same trigger,...
0
by: toughguy | last post by:
Hi Friends, Iam Leela from India. I want to track when a Trigger defined on a particular table is run in MS SQL 2000. I have a table on which i have trigger for insertion, update, deletion...
1
by: John Hopfield | last post by:
Hi to all, Can you make a (simple) example about logging table changes into a "log" table? It is possible using triggers? thank you JH
1
by: ChrisC | last post by:
Hello, I am attempting to create a trigger to keep track of changes to a table, mainly about specific changes to the data in the table. I had hoped that triggers defined as for each row would...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.