array - user_zoned_ids
IF NULL = ANY(user_zones_ids) THEN
Do Something
END IF;
But IF condition is always giving false even if NULL is present in array
You can't use the ANY operator to check for NULL values. You have to unnest the array and count the number of NULL elements:
if (select count(*) from unnest(user_zones_ids) as t(x) where x is null) > 0 then
... do something ...
end if;
array.count(element) someday.select exists(select * from unnest(ARRAY[1,2,3, null]) g(v) where v is null);
is nullinstead of= null?