Submitted on: 04-12-2001
Description:
Used inside PL/pgSQL functions when you're not sure a variable_name will return an acceptable value. This catches NULL's and 0's and makes sure you do at least get a numerical value.
Code:
(CASE WHEN (var_name ISNULL or var_name = 0) THEN 0 ELSE var_name END)
i.e.
select display_value((CASE WHEN age ISNULL or age = 0) THEN 0 ELSE age END));
Justin Clift
justin@postgresql.org
|