Search Postgresql Archives

Re: regular expressions in query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



elein wrote:
No doubt someone more adept at perl can write
this function as a one-liner.

create or replace function just_digits(text)
returns text as
$$
        my $innum = $_[0];
        $innum =~ s/\D//g;
        return $innum;
$$ language 'plperl'

     SELECT telephone FROM addresses
        WHERE user_id = 'bob'
        AND just_digits(telephone) = '1115551212';

--elein


I've thought about things like this in the past, and a thought that occurred to me was to add a functional index on just_digits(telephone) to the table. Would this not allow the above query to use an index while searching?


--

Russ.

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux