是阵列中的所有PostgreSQL的空值 [英] Is array all NULLs in PostgreSQL
问题描述
时,如果有一个PostgreSQL阵列中的所有元素都为空返回TRUE一个前pression?
Is there an expression that returns TRUE if all the elements of a PostgreSQL array are NULL?
如果这是一个值NULL以外,当然我可以使用类似:
If it was a value other than NULL, I could of course use something like:
SELECT 4 = ALL (ARRAY[4,5]::integer[]);
不过,我想要做的所有操作与 IS NULL
测试,而不是一个 = 4
测试。我不认为有一个这样的所有的语法,并围绕NULL的语义与阵列,我不是我自己能想实现它的一种形式复杂。因此,我要求堆栈溢出。 ; - )
However I want to do the ALL operation with an IS NULL
test, rather than a = 4
test. I don't think there's an ALL syntax for this, and the semantics around NULL are compounded with arrays I've not myself been able to think of a form that achieves it. Hence my asking Stack Overflow. ;-)
我知道我可以写在PL / SQL函数或PL / pgSQL里做这个,但我想看看是否有诉诸之前直接EX pression。
I know I could write a function in pl/sql or pl/pgsql that does this, but I'd like to see if there's a direct expression before resorting to that.
推荐答案
我觉得我得到了最简单的回答,但仍preserving 4 = ALL(ARRAY [4,5] ::整数[]);
构造:
I think I got the shortest answer, while still preserving 4 = ALL (ARRAY[4,5]::integer[]);
construct:
select
y, true = ALL (select unnest(z) is null)
from x
这篇关于是阵列中的所有PostgreSQL的空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!