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