For an Integer or Number field, does it make more sense to default values to
NULL or 0?
When used for calculations, a column with NULL could cause a problem (eg.
NULL * 2).
Columns with NULL will be ignored in and SQL count, but columns with a 0
will be counted.
Is this right? Are there other
Nulls have always caused me a problem... I avoid them like the plauge...
__
Dedicated Windows 2000 Server
PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
Instant Activation · $99/Month · Free Setup
.
For this reason I usually default to 0 rather than NULL. When you do thi
s,
you have the added benifit in CF of being able to use the value as if it
were a boolean, as in:
Cfif myquery.myIntergerColumn
If the column is NOT 0, this executes
cfelseif NOT myquery.myIntegerColumn
-Talk
Subject: RE: NULL or 0
If you are using CF, remember that NULL is returned as a zero length
stri
ng
( ' ') which is not the same as NULL. If you have code that evaluates
or
calculates in CF using that column, you either must default to a
numeric
value or validate the numericity
this to be a coincidence.
Doug Brown
- Original Message -
From: Mark A. Kruger - CFG [EMAIL PROTECTED]
To: CF-Talk [EMAIL PROTECTED]
Sent: Thursday, January 31, 2002 9:51 AM
Subject: RE: NULL or 0
If you are using CF, remember that NULL is returned as a zero length
stri
ng
( ' ') which
, January 31, 2002 9:07 AM
To: CF-Talk
Subject: Re: NULL or 0
There is a nice custom tag for this on the developers exchange, I
believe they have it set to change all ' ' values to NULL if found, but
easy to change to 0. it is called NULL_VALIDATE.
There are two major products that come out
Mark A. Kruger - CFG wrote:
Come to think of it - if you are using MSSQL you can use the ISNULL( )
function to acheive that result - it replaces a null with a default value
as
in:
SELECT IsNull(MyintColumn,0) AS MyintColumn
of course design wise 0 can be better than NULL as null values are
to a
numeric
value or validate the numericity (is that a word) in the application
code.
For this reason I usually default to 0 rather than NULL. When you do
thi
s,
you have the added benifit in CF of being able to use the value as if
it
were a boolean, as in:
Cfif
That's true, but there may be times when NULL is appropriate - and not ev
ery
column has an index.
-Original Message-
From: Zac Spitzer [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 31, 2002 11:37 AM
To: CF-Talk
Subject: Re: NULL or 0
Mark A. Kruger - CFG wrote:
Come to think
9 matches
Mail list logo