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

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -