Beautiful NULL handling routine
Posted in 1994
A programmer at work has recently been working with Oracle and wrote the following 4GL routine (apparently based on a function built into O). Instead of filling your programs with: IF l_value IS NULL THEN or: IF l_value IS NULL LET l_value = 0 OR l_value = 0 THEN... END IF Use: LET l_value = nvl(l_value, 0) or: IF nvl(l_value, 0) = 0 THEN... ------------------------------- Cut here ------------------------------- FUNCTION nvl(l_value, l_nullvalue) DEFINE l_value CHAR(80), l_nullvalue CHAR(80) IF l_value IS NULL THEN RETURN l_nullvalue END IF RETURN l_value END FUNCTION ------------------------------- Cut here ------------------------------- It's short and it's simple, and it's bloody wonderful! - Kerry S --------------------------------------,------------------------------------- Kerry Sainsbury, kerry@kcbbs.gen.nz | THE INFORMIX FAQ Quanta Systems, Auckland, New Zealand | kcbbs.gen.nz:/informix/* | mathcs.emory.edu:/pub/informix/faq/* +64 9 377-4473 (work) 276-5546 (home) | quasar.ucar.edu:/?