Re: Regexp matching + typecasts - Mailing list pgsql-general

From Tom Lane
Subject Re: Regexp matching + typecasts
Date
Msg-id 12065.1395668842@sss.pgh.pa.us
Whole thread Raw
In response to Regexp matching + typecasts  (Ilya Ivanov <forn@ngs.ru>)
Responses Re: Regexp matching + typecasts  (Ilya Ivanov <forn@ngs.ru>)
List pgsql-general
Ilya Ivanov <forn@ngs.ru> writes:
> I need to find all active (status=0) items not belonging to any active
> trigger. The best I could come up with is this:

> select count(itemid) from items where status='0' and itemid not in (select
> cast(regexp_matches(expression,'{([^}]+)}','g') as integer) from triggers
> where status='0');

> However, the cast doesn't work:
> ERROR:  cannot cast type text[] to integer

Well, yeah.  You need to convert the possibly-multiple match results into
a set.  Try putting unnest() around the regexp_matches call.

            regards, tom lane


pgsql-general by date:

Previous
From: Granthana Biswas
Date:
Subject: Re: Dead rows not getting removed during vacuum
Next
From: Tom Lane
Date:
Subject: Re: Dead rows not getting removed during vacuum