Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Trigger to keep a single record form a table to a certain status

715410Aug 3 2009 — edited Aug 4 2009
Hi all.

I have a table which has a "Status" field. I'm trying to accomplish, with a trigger, that the table can only have one record with an "Active" status, so whenever and Insert or Update occurs, if the new value for the "Status" field is "Active", I should update all other records in the table to "Inactive". I've tried several approaches, and managed to make it work on Inserts, but any Updates wll give an error that says that the table is mutating. I've tried to do it on before and after trigger types, without success.

Is there a way to do what I want with a trigger, or do necessarily I have to create an SP that needs to be called before the Insert or Update operation?
This post has been answered by Frank Kulash on Aug 3 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 1 2009
Added on Aug 3 2009
16 comments
1,612 views