¿Existe un operador de comparación donde a.unitnum = b.unitnum sería true si tanto a.unitnum como b.unitnum son nulos? Parece que a.unitnum ES b.unitnum no es válido
sí, hayIS DISTINCT FROM y IS NOT DISTINCT FROM
postgres=# \pset null **** Null display is "****". postgres=# select null = null; ┌──────────┐ │ ?column? │ ╞══════════╡ │ **** │ └──────────┘ (1 row) postgres=# select null is not distinct from null; ┌──────────┐ │ ?column? │ ╞══════════╡ │ t │ └──────────┘ (1 row) postgres=# select 10 = null; ┌──────────┐ │ ?column? │ ╞══════════╡ │ **** │ └──────────┘ (1 row) postgres=# select 10 is distinct from null; ┌──────────┐ │ ?column? │ ╞══════════╡ │ t │ └──────────┘ (1 row) postgres=# select 10 is not distinct from null; ┌──────────┐ │ ?column? │ ╞══════════╡ │ f │ └──────────┘ (1 row) postgres=# select 10 is not distinct from 20; ┌──────────┐ │ ?column? │ ╞══════════╡ │ f │ └──────────┘ (1 row)Sí, lo hay , pero se recomienda no usarlo . aquí está la muestra:
t=# select null = null; ?column? ---------- (1 row) t=# set transform_null_equals = on; SET t=# select null = null; ?column? ---------- t (1 row) ACTUALIZACIÓN: aparentemente solo funcionaría para la column = NULL , no para la columna = columna:
t=# with s as (select null::int a, null::int b) select a <> b from s; ?column? ---------- (1 row)entonces la comparación más corta sería coalesce:
t=# with s as (select null::int a, null::int b) select coalesce(a,b,0) = 0 from s; ?column? ---------- t (1 row)IF(a.unitnum IS null AND b.unitnum IS null) THEN RAISE NOTICE 'unitum field is null in both a and b tables' ELSE RAISE NOTICE 'unitum field is not null in at least one a or b tables' END IF;