| From: | "Tobias Anstett" <tobias(dot)anstett(at)iaas(dot)uni-stuttgart(dot)de> |
|---|---|
| To: | <pgsql-general(at)postgresql(dot)org> |
| Subject: | How to check if an array is empty |
| Date: | 2008-09-11 06:42:07 |
| Message-ID: | 002b01c913d9$82559e90$8700dbb0$@anstett@iaas.uni-stuttgart.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tommy Gildseth | 2008-09-11 06:49:22 | Re: "Stuck" query |
| Previous Message | Artacus | 2008-09-11 05:45:28 | Re: No error when column doesn't exist |