Search Postgresql Archives

How to check if an array is empty

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

 

in my special case I’d like to check if a XML[] is empty, because postgres doesn’t implement any equality operators, this is not a ‘simple’ task.

 

My current solution is:

 

SELECT * FROM sometable WHERE XMLSERIALIZE(CONTENT ((XPATH('/a:bar, somexmlcolumn, ARRAY[ARRAY['a', 'http://foo]]))[1]) AS text)<>''

 

But there must be a better way – maybe I missed something important - I also tried queries like the following:

 

SELECT * FROM sometable WHERE (XPATH('/a:bar', somexmlcolumn, ARRAY[ARRAY['a', 'http://foo']]))<>('{}'::XML[])

 

Any ideas and feedback are welcome.

 

Cheers, Tobias


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux