I am using Oracle 12c. I have a table named myTestTab and that table has a column named "active". The column is defined as
ACTIVE varchar2(1) So that only one character can be entered in that column. Now, for this column,
- There can be no more than one row that can have value 'Y' in it.
- Additionally, have to add a check constraint so that nothing but a 'Y' can be entered into that column (to prevent the user from entering any other value).
So far, to match the requirement I have created an index on that table as:
create unique index only_one_yes on myTestTab (case when upper(ACTIVE)='Y' then 'Y' else '' end); However, it's not setting lower-case 'y' as upper-case 'y' and it is accepting any other character as long as it is unique. May I get any idea on how to fix it?