Re: if !NULL ?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Lev Lvovsky <lists1(at)sonous(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: if !NULL ?
Date: 2002-05-17 01:17:24
Message-ID: 20020516181508.K1443-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 16 May 2002, Lev Lvovsky wrote:

>
> ok, so more odd-ball questions
>
> I have two columns in a table:
>
> bool_bill | billing_id
>
> one is a boolean that determines if we bill a customer, and the other one
> is NULL if we don't, and has a billing_id of that customer if we do. the
> billing_id uses a foreign key on the billing table to check that the
> billing_id exists.
>
> what I'd like to do is if bool_bill = y, then there has to be something in
> billing_id (automatically checked with the foreign key).
>
> again, do I need a function for this?

I think a table check constraint like:
(bool_bill=false or billing_id is not null)
will make billing_id not accept nulls when bool_bill is true.

In response to

  • if !NULL ? at 2002-05-16 23:40:51 from Lev Lvovsky

Browse pgsql-general by date

  From Date Subject
Next Message Xinlin Qian 2002-05-17 02:03:04 ERROR: SET TRANSACTION ISOLATION LEVEL must be called before any query
Previous Message Stephan Szabo 2002-05-17 01:15:06 Re: foreign key reference on array elements?