Invalid Use of Null

  • Thread starter Thread starter AL
  • Start date Start date
A

AL

I've been retrieving values using ADO, and setting those
values to a variable MTDSALES (for month to date sales)
which is declared as double.

The problem is that when the retrieved value is Null
I get an error "Invalid Use of Null". Any ideas on how to
handle this situation efficiently?

I could send all retrieved values to a function which
checks for the NUll case and then sends back 0.00 if it is
Null but I'm not sure if this the best way to go about it.

Thanks in advance.
 
if isnull(something) then
MTDSALES = 0.0
else
MTDSALES = Something
End if
 
AL said:
I've been retrieving values using ADO, and setting those
values to a variable MTDSALES (for month to date sales)
which is declared as double.

The problem is that when the retrieved value is Null
I get an error "Invalid Use of Null". Any ideas on how to
handle this situation efficiently?

Review whether is it possible to change the database column's
definition to NOT NULL and provide a DEFAULT value e.g. zero. If this
does not fit your business rules i.e. a NULL ('not known') value has
distinct meaning from zero, then rewrite the query using a CASE (or
equivalent syntax) to provide a value in place of a NULL.

Jamie.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top