From: Michael Pohl <pgsql@newtopia.com>
To: pgsql-sql@postgresql.org
Cc: Tom Rochester <tomr@chu.com.au>
Subject: Re: substr_count
Date: Thu, 10 Jul 2003 08:55:59 -0400 (EDT)
Message-ID: <Pine.LNX.4.44.0307100843370.13741-100000@server1.techplant.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0307092104480.6784-100000@server1.techplant.com>
On Thu, 10 Jul 2003, Tom Rochester wrote:
> I would like to achive something along the lines of:
>
> SELECT field FROM table WHERE field ILIKE '$searchterm' ORDER BY
> substr_count(field, '$searchterm');
If you have plperl installed:
create or replace function substr_count(
varchar(255),
varchar(255)
)
returns int as '
my ($field, $searchterm) = @_;
my $count = $field =~ s/$searchterm//g;
return $count;
' language 'plperl';
michael
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: pgsql@newtopia.com, tomr@chu.com.au
Subject: Re: substr_count
In-Reply-To: <Pine.LNX.4.44.0307100843370.13741-100000@server1.techplant.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox