Subject RE: [firebird-support] Re: String Calc/Index
Author Alan McDonald
> > I have a column containing mobile phone numbers in the following
> format
> > 04XX XXX XXX
> > I need to search this table efficiently based on a known number in
> the
> > format
> > 04XXXXXXXX
> > So I need to either create a calculated column or an index which will
> > provide efficiency in
> > SELECT ID FROM TABLE WHERE MYCOLUMN='04XXXXXXXX'
> >
> > Does anyone have any ideas of the best way?
> >
> > In Delphi I just have a stripspaces and trim function which does the
> job for
> > comparison. This is fine when I move thru a subset of the values but
> I'd
> > like to grab the number from the entire table efficiently if
> possible.
>
> I may be making assumptions about the phone numbering system in your
> local area, but can you assume that any number starting with 04 is a
> mobile and any number not starting with 04 is not?
>
> If that assumption is OK,
>
> SELECT ID FROM TABLE WHERE MYCOLUMN STARTING WITH '04'
>
> With an index on TABLE.MYCOLUMN
>
> Adam

Actually they are all mobiles. they all start with 04 so STARTING WITH '04'
will return all rows...
Anyway- I found the F_STRIPSTRING function in the FreeUDFLib and it works
perfectly. I can create an index with it if I want or just use it in the
where clause.
Hmmm, I wonder where the performance cutoff would be,.. maintaining this
index Versus querying directly with it.
Alan