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

From Ilya Ivanov
Subject Re: Regexp matching + typecasts
Date
Msg-id CAA=KoeJynz8Yr0izWMr74XbznuqQ2wPV+8R9ZT0kgWy6H2Z3Uw@mail.gmail.com
Whole thread Raw
In response to Re: Regexp matching + typecasts  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Thanks Tom, that worked!


On Mon, Mar 24, 2014 at 8:47 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
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



--
Ilya.

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Postgres 9.2.8 crash sporadically on Windows
Next
From: Nithya Soman
Date:
Subject: How do you find the row count for all your tables in Postgres?