Home » SQL & PL/SQL » SQL & PL/SQL » Trigger
Trigger [message #309002] Wed, 26 March 2008 03:50 Go to next message
Messages: 119
Registered: August 2007
Senior Member

This is the scenario I am facing:

table emp
fields dept, empno, empname, empadd, empphone.

I wish to write a trigger which would update the field dept to 'IT'
when the empno is 123 and the empname is updated.

However, one restriction I have here is that only when empname is updated dept must be changed to IT.

If empadd or empphone are changed the field dept must not be updated.

Is this possible using a trigger?

If not, could you please suggest another way out?


Re: Trigger [message #309005 is a reply to message #309002] Wed, 26 March 2008 03:57 Go to previous messageGo to next message
Messages: 20847
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Yes, it is possible. Check the CREATE TRIGGER syntax; pay attention to DML_EVEN_CLAUSE (for example, ... before update OF column_name).
Re: Trigger [message #309007 is a reply to message #309002] Wed, 26 March 2008 03:59 Go to previous message
Michel Cadot
Messages: 63924
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Yes, it is possible, either use the WHEN clause in CREATE TRIGGER part or check if you update the correct column using UPDATING function.

Previous Topic: Can DBLink can process the same record twice
Next Topic: SQL query - help needed
Goto Forum:

Current Time: Wed Oct 26 05:16:29 CDT 2016

Total time taken to generate the page: 0.08597 seconds