Re: substr_count - Mailing list pgsql-sql

From Michael Pohl
Subject Re: substr_count
Date
Msg-id Pine.LNX.4.44.0307100843370.13741-100000@server1.techplant.com
Whole thread Raw
In response to substr_count  (Tom Rochester <tomr@chu.com.au>)
List pgsql-sql
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



pgsql-sql by date:

Previous
From: Rod Taylor
Date:
Subject: Re: Recursive request ...
Next
From: Michael A Nachbaur
Date:
Subject: Re: help yourself by helping others