473,394 Members | 1,869 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,394 software developers and data experts.

Trigger to reflect changes

1
Hi,

I have created a trigger as below to update a table called vnd_trail to show what sort of operation(update/delete) happened to the name column. My problem is, I want to have another column to show the changes that took place. For example name field: maxim systems has been changed to maximus system. How can I do that in my trigger below?

CREATE TRIGGER vnd_chk
AFTER UPDATE OR DELETE ON vnd
FOR EACH ROW
DECLARE
oper varchar2(8);
ruid number;
name varchar2(64);
name_change varchar2(64);

BEGIN
if updating then
oper:='update';
end if;

if deleting then
oper:='delete';
end if;

/*store previous value into vnd_trail*/
ruid:=:old.ruid;
name:=:old.name;
insert into vnd_trail
values(ruid,name,oper,sysdate,name_change);
END;

thank you for any advice.
Jul 17 '06 #1
1 2652
masdi2t
37
Hi,
let's say that you have another column named 'desc',
you need a little modification on your trigger

CREATE TRIGGER vnd_chk
AFTER UPDATE OR DELETE ON vnd
FOR EACH ROW
DECLARE
oper varchar2(8);
ruid number;
name varchar2(64);
name_change varchar2(64);

/* additional */
desc varchar2(255);

BEGIN
if updating then
oper:='update';

/* additional */
desc := concat('value: ', old.name, ' was changed to: ', new.name);
end if;

if deleting then
oper:='delete';

/* additional */
desc := concat('value: ', old.name, ' was deleted');
end if;

/*store previous value into vnd_trail*/
ruid:=ld.ruid;
name:=ld.name;
insert into vnd_trail
values(ruid,name,oper,sysdate,name_change, /* additional */desc);
END;
Jul 27 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Tushar | last post by:
Hello, I am working on a client server application involving TOMCAT as Web server, MySQl as the DB and combination of JSP, Servlet, and JavaBeans to access and write Data back. There is...
0
by: Gill Bates | last post by:
so DOM calls should be calculated from Diff. Possible? How? (some URLs please) I guess this is in most cases not very efficient, but here's why: I have a data Document at the server. From...
2
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
1
by: =?Utf-8?B?QnJhbmRvbg==?= | last post by:
Hi, I have an aspx page that contains an include section which calls an html page for text to be displayed on the aspx page. I also have an upload page that allows users to upload a simple html...
0
by: AliRezaGoogle | last post by:
Dear members, I have a datagrid and a textbox on my form. I bound both of them to a common datasource( an arbitrary datatable). When I change a text inside textbox I expect that value of same...
2
by: ejamnadas | last post by:
I have an unbound form, whose combobox and textboxes are also unbound. The form's record source is a query (getdata) . It has combo box whose rowsource is the same query. The afterupdate event...
0
by: \Ji Zhou [MSFT]\ | last post by:
Hello Ashutosh, I see your points. As to your two new concerns, I am give the detailed comments in the following. 1. Is it possible to achieve this result without calling Update on the route...
1
by: amitjaura | last post by:
Well i have a datagridview in my application and i want it to reflect any changes made in server database instantly with some trigger or so? I have a choice to use timer and get the desired results...
3
by: kiranvn31 | last post by:
Hi My flash file get images from one folder with C# code file I changes the image in the folder dynamically on button click flash not show changes on post back but when I close IE and run...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.