Re: xpath() subquery for empty array

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: xpath() subquery for empty array
Date: 2009-07-12 21:17:55
Message-ID: 20090712211755.GW5407@samason.me.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, Jul 12, 2009 at 09:49:15PM +0100, Roy Walter wrote:
> Where exactly does that fit in terms of my original query, i.e.:
>
> SELECT x
> FROM (SELECT xpath('//entry[contains(p, ''searchtext'')]/@*', docxml)
> AS x FROM docs) AS y WHERE x <> [test for empty array?????????]

Something like the following should do the right thing:

SELECT x FROM (
SELECT xpath('//entry[contains(p, ''searchtext'')]/@*', docxml) AS x
FROM docs) AS y
WHERE array_upper(x, 1) > 0;

--
Sam http://samason.me.uk/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Roy Walter 2009-07-12 21:36:15 Re: xpath() subquery for empty array
Previous Message Brent Wood 2009-07-12 20:52:49 Re: indexes on float8 vs integer