Unix Technical Forum

constraint to allow multiple nulls

This is a discussion on constraint to allow multiple nulls within the Informix forums, part of the Database Server Software category; --> Hi All, I have a column that can only have one 'Y' value and multiple NULL values. An unique ...


Go Back   Unix Technical Forum > Database Server Software > Informix

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-20-2008, 09:56 AM
Zev Berezin
 
Posts: n/a
Default constraint to allow multiple nulls


Hi All,

I have a column that can only have one 'Y' value
and multiple NULL values. An unique constraint allows one null value
and a PK allows none. Is there any constraint that would
enforce this?

Tech Spec: IDS 7.31.FD7

TIA,
Zev Berezin
sending to informix-list
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-20-2008, 09:57 AM
Art S. Kagel
 
Posts: n/a
Default Re: constraint to allow multiple nulls

Zev Berezin wrote:
> Hi All,
>
> I have a column that can only have one 'Y' value
> and multiple NULL values. An unique constraint allows one null value
> and a PK allows none. Is there any constraint that would
> enforce this?
>
> Tech Spec: IDS 7.31.FD7


So to expand: You have a table with a CHAR column that is either 'Y' or NULL
and only one row can contain 'Y' at a time. Correct?

So, you need a check constraint to restrict the possible non-null values to
'Y' only and INSERT and UPDATE triggers to validate that if the current row
is being inserted/updated to contain 'Y' that there are no other rows
already containing 'Y'. The update trigger can do the check in an AFTER
clause since the UPDATE could be updating the current 'Y' to not 'Y' and
some other row to 'Y' in the same statement.

Art S. Kagel
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:39 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com