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: 21127
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: 65085
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: Sun Jul 23 23:59:05 CDT 2017

Total time taken to generate the page: 0.04111 seconds