Re: Only target lines of text

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Moore <michaeljmoore(at)gmail(dot)com>
Cc: postgres list <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Only target lines of text
Date: 2016-11-15 01:57:40
Message-ID: 24697.1479175060@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Michael Moore <michaeljmoore(at)gmail(dot)com> writes:
> how can I change this so that it only shows me the lines of text containing
> the matching string?

> SELECT
> proname AS functionname,
> prosrc AS source
> FROM
> pg_proc
> WHERE
> prosrc ~* 'ypoi_db';

You mean you just want part of each prosrc entry? Try something like

select * from
(select proname, unnest(string_to_array(prosrc, '\n')) as l from pg_proc) ss
where l ~* 'ypoi_db';

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Moore 2016-11-15 03:07:37 Re: Only target lines of text
Previous Message Rob Sargent 2016-11-15 01:36:57 Re: Only target lines of text