Re: UNIQUE OR NULL
Posted in 1995
Achim Reiners (ar@schleupen-gw-koeln.de) wrote: : Hy Guys, : I have a column that may contain NULL values but if there is a value different : from NULL this has to be unique. I.e. in other words no value except of NULL may : occur more than once. : Question: How do I explain this in INFORMIX by a constraint or by other means? : I would NOT prefer a trigger solution but declarative means, of course. Hi ! Instead of trigger You may use VIEW with filter condition "NOT key IS NULL" in conjunction with UNIQUE INDEX on that key. It may be better than using triggers, if You will use this view in queries. However such a problem seems rather strange to me. Key field containing NULL's is usually FOREIGN KEY and don't need checking for uniqueness - this checking is performed on it's corresponding PRIMARY KEY. With best regards, Vadim J. Nikitin