sql - Oracle. Constrain one row to have a certain value -


I want to add an obstacle to a table where in one column there is only one row at the same time with the value May be.

For example create a table of MyTable .... position varchar (1); )

A check on the Status column will be 'O', 'C', 'P' for open, closed or pending.

Multiple shutdowns and pending can be open but only one row (or none) in the table can be open.

Any indication appreciated.

Create a unique function index:

  Unique index Mayandex and MyTable Create on (case status when 'o' then 'he' end);  

This prevents the value from entering two 'O' values, but will allow other duplicate values.


Comments

Popular posts from this blog

scala - Play Framework - how to bind form to a session field -

Django Celery - running scheduled tasks -

perl - 'Unquoted string ".." may clash with future reserved word' but only when package is used -