Board index » delphi » numeric value + null = null

numeric value + null = null

Hye,

What is the best way to solve the "old problem" :
1 + NULL = NULL.
I would like 1 + NULL = 1

I have some complex query (as stocks calculations), where I can't guarantee
that there won't be null value, even if I force non null values.

Is there any general article dealing with this problem.

Is the use of udf a good direction. Do you have a standard udf converting
any numeric values or null value.
Ex : fct(num_value)= num_value
fct(null) = 0

Thanks
Daniel

Re:numeric value + null = null

Quote
Daniel wrote:

> Hye,

> What is the best way to solve the "old problem" :
> 1 + NULL = NULL.
> I would like 1 + NULL = 1

> I have some complex query (as stocks calculations), where I can't guarantee
> that there won't be null value, even if I force non null values.

NULL is not a value it is a state.  If you want NULL to = 0 then store 0.  If
you want to be able to evaluate the if a value has been stored, then store NULL
and filter out NULL states in your where clause.  Finally you can handle this in
a StoredProc where you can control the sum much easier.

Quote
> Is there any general article dealing with this problem.

> Is the use of udf a good direction. Do you have a standard udf converting
> any numeric values or null value.
> Ex : fct(num_value)= num_value
> fct(null) = 0

> Thanks
> Daniel

--
Jeff Overcash (TeamB)   On waves of silver I dreamed of gold
(Please do not email    'Till I lost the peace that dreaming gives
me directly unless     I dreamed of the moment of my own death
asked.  Thank You)     That no one ever dreams and lives (Marillion)