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!

Column with a specific value allowed in only one row

649635Jul 11 2008 — edited Jul 12 2008
Hi!

I want to implement a simple boolean logic where the value of a char column named 'active' can have a value of 'Y' in only one row. When the value is set to 'Y' for this row, the row which had that column set to 'Y' previously should be set to 'N'.

I solved this with two triggers. Since I can't update the column in an for each row trigger, I introduced another column 'actived_just_set' that I set to 'Y' in the for each row trigger and then in a statement trigger I set all rows with active='Y' and active_just_set<>'Y' to active='N' and then I clean up and set active_just_set='N' for all rows.

This works, but seems clumsy. I don't like to have an extra column for data integrity also.

Thanks for your help,
Marcus
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 8 2008
Added on Jul 11 2008
5 comments
1,489 views