Re: Problem with NULL values
Posted in 2000
Topics: General Discussion
From: Thomas Parsli <thomas.parsli@startsiden.no>
>
>Carlos Benjamin <benj@linuxstart.com> writes:
>
> > Colin Thu <ly-cong.thu@pp.inet.fi> wrote:
> >
> > >I have some problem with my Query (SQL). It's about NULL values.
> > >
> > >SELECT ordernro, quantity, sent, (quantity - sent ) as 'q_left'
> > >FROM orders> > >
> > >So, If sent = NULL then (quatity - sent) is not "quantity". It'll
>become
> > >NULL too. So, I need the real value for "q_left".
> >
> > Hate it when that happens.
> >
> > Unless you have some compelling reason to have nulls in there, I'd fix
>those columns to disallow nulls and change your application to default to
>zeroes. Then update the table to set sent to 0 where sent is null.
>
>Fields like this deserves a DEFAULT value _and_ a NOT NULL.
>And I'd rather use -2,147,483,647 as an indicator of "unknown" than
>NULL...
And your reason for this is....?
>CREATE TABLE orders (
> ...
> quantity INTEGER NOT NULL DEFAULT 0,
> ...
> )
So your default isn't "unknown"?
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
"Obnoxio The Clown" <obnoxio@hotmail.com> writes:
> From: Thomas Parsli <thomas.parsli@startsiden.no>
> >
> >Carlos Benjamin <benj@linuxstart.com> writes:
> >
> > > Colin Thu <ly-cong.thu@pp.inet.fi> wrote:
> > >
> > > >I have some problem with my Query (SQL). It's about NULL values.
> > > >
> > > >SELECT ordernro, quantity, sent, (quantity - sent ) as 'q_left'
> > > >FROM orders> > > >
> > > >So, If sent = NULL then (quatity - sent) is not "quantity". It'll
> >become
> > > >NULL too. So, I need the real value for "q_left".
> > >
> > > Hate it when that happens.
> > >
> > > Unless you have some compelling reason to have nulls in there, I'd fix
> >those columns to disallow nulls and change your application to default to
> >zeroes. Then update the table to set sent to 0 where sent is null.
> >
> >Fields like this deserves a DEFAULT value _and_ a NOT NULL.
> >And I'd rather use -2,147,483,647 as an indicator of "unknown" than
> >NULL...
>
> And your reason for this is....?
I don't like NULLS? -The reasons for this I don't know;)
> >CREATE TABLE orders (
> > ...
> > quantity INTEGER NOT NULL DEFAULT 0,
> > ...
> > )>
> So your default isn't "unknown"?
It depends on the buisness-rules -which I know nothing of and therefore
should shut up. (I will...)
(I'd say zero is a good unknown, but I'm shutting up over here)
Thomas