NULLS in ACE variables
Posted in 2000
Daryl,
On the subject of NULLS and '' in ACE:
If you happen to write ace reports with user input variables, but
you want the select statement to grab all records even those with
NULLS in the fields associated with the input, you have to write a
two-option "OR" clause for each input field.
Say you defined some variables and an input stmt for fields "x" and "y"
in your ACE report
select x, y, z
from tab1
where x matches $var1
and y matches $var2
If the user puts "*" in the $var1 and $var2 fields, only records with those
fields NOT EQUAL to NULL will be selected ("*" does not match NULL values).
If you want to allow the select to grab everything including NULL values if
the user leaves the input field blank, you have to modify the select stmt.
Here's a method suggested a while ago by Jonathan Leffler:
select x, y, z
from tab1
where (x matches $var1 or $var1 = '')
and (y matches $var2 or $var2 = '')
--
Colin